|
| 1 | +# This file is copied to spec/ when you run 'rails generate rspec:install' |
| 2 | +ENV['RAILS_ENV'] ||= 'test' |
| 3 | +require File.expand_path('../config/environment', __dir__) |
| 4 | +# Prevent database truncation if the environment is production |
| 5 | +abort('The Rails environment is running in production mode!') if Rails.env.production? |
| 6 | +require 'rspec/rails' |
| 7 | +# Add additional requires below this line. Rails is not loaded until this point! |
| 8 | + |
| 9 | +# Requires supporting ruby files with custom matchers and macros, etc, in |
| 10 | +# spec/support/ and its subdirectories. Files matching `spec/**/*_helper.rb` can |
| 11 | +# be required explicitly. |
| 12 | +Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } |
| 13 | + |
| 14 | +# Checks for pending migration and applies them before tests are run. |
| 15 | +# If you are not using ActiveRecord, you can remove these lines. |
| 16 | +begin |
| 17 | + ActiveRecord::Migration.check_all_pending! |
| 18 | +rescue ActiveRecord::PendingMigrationError => e |
| 19 | + puts e.to_s.strip |
| 20 | + exit 1 |
| 21 | +end |
| 22 | +RSpec.configure do |config| |
| 23 | + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures |
| 24 | + config.fixture_paths = ["#{::Rails.root}/spec/fixtures"] |
| 25 | + |
| 26 | + # If you're not using ActiveRecord, or you'd prefer not to use each of your |
| 27 | + # test frameworks (like Capybara or Selenium) for test |
| 28 | + # see https://relishapp.com/rspec/rspec-rails/docs/configuration |
| 29 | + config.use_transactional_fixtures = true |
| 30 | + |
| 31 | + # RSpec Rails can automatically mix in different behaviours based on the |
| 32 | + # file location of the spec. This line needs to be present for ViewComponent |
| 33 | + # to work with controller specs |
| 34 | + config.infer_spec_type_from_file_location! |
| 35 | + |
| 36 | + # Filter lines from Rails gems in backtraces. |
| 37 | + config.filter_rails_from_backtrace! |
| 38 | + # arbitrary gems may also be filtered from backtraces |
| 39 | + # this line is optional and should be present if your application depends |
| 40 | + # on external gems, but this is not needed for ViewComponent tests |
| 41 | +end |
0 commit comments