|
2 | 2 | require 'spec_helper' |
3 | 3 | ENV['RAILS_ENV'] ||= 'test' |
4 | 4 | require_relative '../config/environment' |
5 | | -# Prevent database truncation if the environment is production |
6 | 5 | abort("The Rails environment is running in production mode!") if Rails.env.production? |
7 | | -# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file |
8 | | -# that will avoid rails generators crashing because migrations haven't been run yet |
9 | | -# return unless Rails.env.test? |
10 | 6 | require 'rspec/rails' |
11 | | -# Add additional requires below this line. Rails is not loaded until this point! |
| 7 | +require_relative 'support/factory_bot' |
12 | 8 |
|
13 | | -# Requires supporting ruby files with custom matchers and macros, etc, in |
14 | | -# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are |
15 | | -# run as spec files by default. This means that files in spec/support that end |
16 | | -# in _spec.rb will both be required and run as specs, causing the specs to be |
17 | | -# run twice. It is recommended that you do not name files matching this glob to |
18 | | -# end with _spec.rb. You can configure this pattern with the --pattern |
19 | | -# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. |
20 | | -# |
21 | | -# The following line is provided for convenience purposes. It has the downside |
22 | | -# of increasing the boot-up time by auto-requiring all files in the support |
23 | | -# directory. Alternatively, in the individual `*_spec.rb` files, manually |
24 | | -# require only the support files necessary. |
25 | | -# |
26 | | -# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } |
27 | | - |
28 | | -# Checks for pending migrations and applies them before tests are run. |
29 | | -# If you are not using ActiveRecord, you can remove these lines. |
30 | 9 | begin |
31 | 10 | ActiveRecord::Migration.maintain_test_schema! |
32 | 11 | rescue ActiveRecord::PendingMigrationError => e |
33 | 12 | abort e.to_s.strip |
34 | 13 | end |
| 14 | + |
35 | 15 | RSpec.configure do |config| |
36 | | - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures |
37 | 16 | config.fixture_paths = [ |
38 | 17 | Rails.root.join('spec/fixtures') |
39 | 18 | ] |
40 | 19 |
|
41 | | - # If you're not using ActiveRecord, or you'd prefer not to run each of your |
42 | | - # examples within a transaction, remove the following line or assign false |
43 | | - # instead of true. |
44 | 20 | config.use_transactional_fixtures = true |
45 | 21 |
|
46 | | - # You can uncomment this line to turn off ActiveRecord support entirely. |
47 | | - # config.use_active_record = false |
48 | | - |
49 | | - # RSpec Rails uses metadata to mix in different behaviours to your tests, |
50 | | - # for example enabling you to call `get` and `post` in request specs. e.g.: |
51 | | - # |
52 | | - # RSpec.describe UsersController, type: :request do |
53 | | - # # ... |
54 | | - # end |
55 | | - # |
56 | | - # The different available types are documented in the features, such as in |
57 | | - # https://rspec.info/features/7-0/rspec-rails |
58 | | - # |
59 | | - # You can also this infer these behaviours automatically by location, e.g. |
60 | | - # /spec/models would pull in the same behaviour as `type: :model` but this |
61 | | - # behaviour is considered legacy and will be removed in a future version. |
62 | | - # |
63 | | - # To enable this behaviour uncomment the line below. |
64 | | - # config.infer_spec_type_from_file_location! |
65 | | - |
66 | | - # Filter lines from Rails gems in backtraces. |
67 | 22 | config.filter_rails_from_backtrace! |
68 | | - # arbitrary gems may also be filtered via: |
69 | | - # config.filter_gems_from_backtrace("gem name") |
| 23 | +end |
| 24 | + |
| 25 | +Shoulda::Matchers.configure do |config| |
| 26 | + config.integrate do |with| |
| 27 | + with.test_framework :rspec |
| 28 | + with.library :rails |
| 29 | + end |
70 | 30 | end |
0 commit comments