@@ -27,72 +27,57 @@ You should know exactly why you are adding each one of them and why is necessary
2727
2828* Install rspec via ` rails generate rspec:install `
2929* Create a bin stub with ` bundle binstubs rspec-core `
30- * Replace the entire contents of ` spec/spec_helper.rb ` with:
30+ * At the top of the ` spec/spec_helper.rb `
3131
3232 ``` ruby
33- # Run code coverage and exclude files with less than 5 lines of code
34- unless ENV [' NO_COVERAGE' ]
35- require ' simplecov'
36- SimpleCov .start ' rails' do
37- add_filter ' app/channels/application_cable/channel.rb'
38- add_filter ' app/channels/application_cable/connection.rb'
39- add_filter ' app/jobs/application_job.rb'
40- add_filter ' app/mailers/application_mailer.rb'
41- add_filter ' app/models/application_record.rb'
42- add_filter ' .semaphore-cache'
43- enable_coverage :branch
44- minimum_coverage line: 100 , branch: 100
45- end
33+ require ' simplecov'
34+ SimpleCov .start " rails" do
35+ add_filter " app/channels/application_cable/channel.rb"
36+ add_filter " app/channels/application_cable/connection.rb"
37+ add_filter " app/jobs/application_job.rb"
38+ add_filter " app/mailers/application_mailer.rb"
39+ add_filter " app/models/application_record.rb"
40+ add_filter " .semaphore-cache"
41+ enable_coverage :branch
42+ minimum_coverage line: 100 , branch: 100
4643 end
44+ ```
45+
46+ to run code coverage and exclude files with less then 5 lines of code.
4747
48- RSpec .configure do |config |
49- config.expect_with :rspec do |expectations |
50- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
51- end
52- config.mock_with :rspec do |mocks |
53- mocks.verify_partial_doubles = true
54- end
55-
56- config.run_all_when_everything_filtered = true
57-
58- # We suggest you to also keep the following enabled:
59- config.disable_monkey_patching!
60- config.default_formatter = ' doc' if config.files_to_run.one?
61- config.profile_examples = 5
62- config.order = :random
63- Kernel .srand config.seed
64-
65- config.define_derived_metadata do |meta |
66- meta[:aggregate_failures ] = true
67- end
48+ * Inside ` spec/spec_helper.rb ` we suggest you to uncomment/enable the following:
49+
50+ ``` ruby
51+ config.disable_monkey_patching!
52+ config.default_formatter = ' doc' if config.files_to_run.one?
53+ config.profile_examples = 5
54+ config.order = :random
55+ Kernel .srand config.seed
56+
57+ config.define_derived_metadata do |meta |
58+ meta[:aggregate_failures ] = true
6859 end
6960 ```
7061
71- * Replace the entire contents of ` spec/rails_helper.rb ` with:
62+ Please check the [ spec_helper template] ( ../templates/spec/spec_helper.rb )
63+
64+ * Add the configurations:
7265
7366``` rb
74- ENV [' RAILS_ENV' ] ||= ' test'
75- require ' spec_helper'
76- require_relative ' ../config/environment'
77- # Prevent database truncation if the environment is production
78- abort (' The Rails environment is running in production mode!' ) if Rails .env.production?
79- require ' rspec/rails'
67+ # spec/rails_helper.rb:
68+
69+ # after `require 'rspec/rails'`
8070require ' capybara/rspec'
8171require ' capybara/rails'
8272require ' selenium/webdriver'
8373require ' super_diff/rspec-rails'
8474
85- ActiveRecord ::Migration .maintain_test_schema!
86-
8775Dir [Rails .root.join(' spec/support/**/*.rb' )].each { |f | require f }
8876
89- RSpec .configure do |config |
90- config.include FactoryBot ::Syntax ::Methods
91- config.include ActiveSupport ::Testing ::TimeHelpers
92- config.include JavaScriptErrorReporter , type: :system , js: true
77+ # ... (omitted configs here)
9378
94- config.use_transactional_fixtures = true
95- config.infer_spec_type_from_file_location!
79+ RSpec .configure do | config |
80+ # ... (omitted configs here)
9681
9782 config.before do |example |
9883 ActionMailer ::Base .deliveries.clear
@@ -108,10 +93,6 @@ RSpec.configure do |config|
10893 driven_by :rack_test
10994 end
11095
111- config.before(:all , type: :system ) do
112- Capybara .server = :puma , { Silent: true }
113- end
114-
11596 config.before(:each , type: :system , js: true ) do
11697 driven_by ENV [' SELENIUM_DRIVER' ]&.to_sym || :selenium_chrome_headless
11798 Capybara .page.current_window.resize_to(1280 , 800 )
134115
135116```
136117
118+ Please check the full [ rails_helper template] ( ../templates/spec/rails_helper.rb ) to compare.
137119
138120* Add the line ` bundle exec parallel_rspec ` to ` bin/check `
139121
@@ -176,3 +158,7 @@ nctl get applications --project={PROJECT_NAME}
176158## Javascript error reporter
177159
178160* Create the module [ ` spec/support/javascript_error_reporter.rb ` ] ( ../templates/spec/support/javascript_error_reporter.rb )
161+
162+ * Verify that ` config.include JavaScriptErrorReporter, type: :system, js: true ` is in your [ ` rails_helper.rb ` ] ( ../templates/spec/rails_helper.rb )
163+
164+ Please check the [ rails_helper template] ( ../templates/spec/rails_helper.rb ) to compare.
0 commit comments