Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. ### New project:
  2.  
  3. ```ruby
  4. rails new Project_Name -d=postgresql --skip-spring --skip-turbolinks
  5. ```
  6.  
  7. ### Project Setup (Rspec):
  8.  
  9. Gems for development, test:
  10. ```ruby
  11. gem 'active_designer'
  12. gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  13. gem 'factory_bot_rails'
  14. gem 'launchy'
  15. gem 'pry'
  16. gem 'rspec-rails'
  17. gem 'shoulda-matchers'
  18. ```
  19.  
  20. Then:
  21. ```
  22. bundle
  23. ```
  24.  
  25. Then:
  26. ```
  27. rails g rspec:install
  28. ```
  29.  
  30. Configure shoulda-matchers & database cleaner.
  31.  
  32. - Both in rails_helper.rb
  33.  
  34. ```ruby
  35. require 'spec_helper'
  36. ENV['RAILS_ENV'] ||= 'test'
  37. require File.expand_path('../../config/environment', __FILE__)
  38.  
  39. abort("The Rails environment is running in production mode!") if Rails.env.production?
  40. require 'rspec/rails'
  41.  
  42. require 'database_cleaner'
  43. Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
  44. DatabaseCleaner.strategy = :truncation
  45. ActiveRecord::Migration.maintain_test_schema!
  46.  
  47. RSpec.configure do |config|
  48. config.include FactoryBot::Syntax::Methods
  49. config.fixture_path = "#{::Rails.root}/spec/fixtures"
  50. config.use_transactional_fixtures = true
  51. config.infer_spec_type_from_file_location!
  52. config.filter_rails_from_backtrace!
  53. DatabaseCleaner.strategy = :truncation
  54.  
  55. RSpec.configure do |c|
  56. c.before(:each) do
  57. DatabaseCleaner.clean
  58. end
  59.  
  60. c.after(:each) do
  61. DatabaseCleaner.clean
  62. end
  63. c.include Capybara::DSL
  64. end
  65. end
  66.  
  67. Shoulda::Matchers.configure do |config|
  68. config.integrate do |with|
  69. with.test_framework :rspec
  70. with.library :rails
  71. end
  72. end
  73. ```
Add Comment
Please, Sign In to add comment