|
6 | 6 | require_relative "../config/environment" |
7 | 7 | # Prevent database truncation if the environment is production |
8 | 8 | abort("The Rails environment is running in production mode!") if Rails.env.production? |
| 9 | +# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file |
| 10 | +# that will avoid rails generators crashing because migrations haven't been run yet |
| 11 | +# return unless Rails.env.test? |
9 | 12 | require "factory_bot" |
10 | 13 | require "devise" |
11 | 14 | require "rspec/rails" |
|
25 | 28 | # directory. Alternatively, in the individual `*_spec.rb` files, manually |
26 | 29 | # require only the support files necessary. |
27 | 30 | # |
28 | | -# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } |
| 31 | +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } |
29 | 32 |
|
30 | | -# Checks for pending migrations and applies them before tests are run. |
| 33 | +# Ensures that the test database schema matches the current schema file. |
| 34 | +# If there are pending migrations it will invoke `db:test:prepare` to |
| 35 | +# recreate the test database by loading the schema. |
31 | 36 | # If you are not using ActiveRecord, you can remove these lines. |
32 | 37 | begin |
33 | 38 | ActiveRecord::Migration.maintain_test_schema! |
34 | 39 | rescue ActiveRecord::PendingMigrationError => e |
35 | | - puts e.to_s.strip |
36 | | - exit 1 |
| 40 | + abort e.to_s.strip |
37 | 41 | end |
38 | 42 | RSpec.configure do |config| |
39 | 43 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures |
40 | | - config.fixture_path = Rails.root.join("spec/fixtures") |
| 44 | + config.fixture_paths = [ |
| 45 | + Rails.root.join("spec/fixtures") |
| 46 | + ] |
41 | 47 |
|
42 | 48 | # If you're not using ActiveRecord, or you'd prefer not to run each of your |
43 | 49 | # examples within a transaction, remove the following line or assign false |
|
47 | 53 | # You can uncomment this line to turn off ActiveRecord support entirely. |
48 | 54 | # config.use_active_record = false |
49 | 55 |
|
50 | | - # RSpec Rails can automatically mix in different behaviours to your tests |
51 | | - # based on their file location, for example enabling you to call `get` and |
52 | | - # `post` in specs under `spec/controllers`. |
| 56 | + # RSpec Rails uses metadata to mix in different behaviours to your tests, |
| 57 | + # for example enabling you to call `get` and `post` in request specs. e.g.: |
53 | 58 | # |
54 | | - # You can disable this behaviour by removing the line below, and instead |
55 | | - # explicitly tag your specs with their type, e.g.: |
56 | | - # |
57 | | - # RSpec.describe UsersController, type: :controller do |
| 59 | + # RSpec.describe UsersController, type: :request do |
58 | 60 | # # ... |
59 | 61 | # end |
60 | 62 | # |
61 | 63 | # The different available types are documented in the features, such as in |
62 | | - # https://relishapp.com/rspec/rspec-rails/docs |
| 64 | + # https://rspec.info/features/8-0/rspec-rails |
| 65 | + # |
| 66 | + # You can also this infer these behaviours automatically by location, e.g. |
| 67 | + # /spec/models would pull in the same behaviour as `type: :model` but this |
| 68 | + # behaviour is considered legacy and will be removed in a future version. |
| 69 | + # |
| 70 | + # To enable this behaviour uncomment the line below. |
63 | 71 | config.infer_spec_type_from_file_location! |
64 | 72 |
|
65 | 73 | # Filter lines from Rails gems in backtraces. |
66 | 74 | config.filter_rails_from_backtrace! |
67 | 75 | # arbitrary gems may also be filtered via: |
68 | 76 | # config.filter_gems_from_backtrace("gem name") |
69 | | - # |
| 77 | + |
70 | 78 | config.include Devise::Test::ControllerHelpers, type: :controller |
71 | 79 | config.include Devise::Test::ControllerHelpers, type: :view |
72 | 80 |
|
|
0 commit comments