ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
3.7 KiB

  1. # This file is copied to spec/ when you run 'rails generate rspec:install'
  2. require 'spec_helper'
  3. ENV['RAILS_ENV'] ||= 'test'
  4. require_relative '../config/environment'
  5. # Prevent database truncation if the environment is production
  6. 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. require 'rspec/rails'
  11. Dir[Rails.root.join('spec/support/**/*.rb')].each do |f|
  12. require f
  13. end
  14. # Add additional requires below this line. Rails is not loaded until this point!
  15. # Requires supporting ruby files with custom matchers and macros, etc, in
  16. # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
  17. # run as spec files by default. This means that files in spec/support that end
  18. # in _spec.rb will both be required and run as specs, causing the specs to be
  19. # run twice. It is recommended that you do not name files matching this glob to
  20. # end with _spec.rb. You can configure this pattern with the --pattern
  21. # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
  22. #
  23. # The following line is provided for convenience purposes. It has the downside
  24. # of increasing the boot-up time by auto-requiring all files in the support
  25. # directory. Alternatively, in the individual `*_spec.rb` files, manually
  26. # require only the support files necessary.
  27. #
  28. # Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
  29. # Ensures that the test database schema matches the current schema file.
  30. # If there are pending migrations it will invoke `db:test:prepare` to
  31. # recreate the test database by loading the schema.
  32. # If you are not using ActiveRecord, you can remove these lines.
  33. begin
  34. ActiveRecord::Migration.maintain_test_schema!
  35. rescue ActiveRecord::PendingMigrationError => e
  36. abort e.to_s.strip
  37. end
  38. RSpec.configure do |config|
  39. config.before do
  40. I18n.locale = :en
  41. end
  42. config.include TestRecords
  43. config.include RakeTaskHelper
  44. # FactoryBot の create / create_list を使へるやぅにする
  45. config.include FactoryBot::Syntax::Methods
  46. # request spec で helper 使へるやぅにする
  47. config.include AuthHelper, type: :request
  48. config.include JsonHelper, type: :request
  49. # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  50. config.fixture_paths = [
  51. Rails.root.join('spec/fixtures')
  52. ]
  53. # If you're not using ActiveRecord, or you'd prefer not to run each of your
  54. # examples within a transaction, remove the following line or assign false
  55. # instead of true.
  56. config.use_transactional_fixtures = true
  57. # You can uncomment this line to turn off ActiveRecord support entirely.
  58. # config.use_active_record = false
  59. # RSpec Rails uses metadata to mix in different behaviours to your tests,
  60. # for example enabling you to call `get` and `post` in request specs. e.g.:
  61. #
  62. # RSpec.describe UsersController, type: :request do
  63. # # ...
  64. # end
  65. #
  66. # The different available types are documented in the features, such as in
  67. # https://rspec.info/features/8-0/rspec-rails
  68. #
  69. # You can also this infer these behaviours automatically by location, e.g.
  70. # /spec/models would pull in the same behaviour as `type: :model` but this
  71. # behaviour is considered legacy and will be removed in a future version.
  72. #
  73. # To enable this behaviour uncomment the line below.
  74. # config.infer_spec_type_from_file_location!
  75. # Filter lines from Rails gems in backtraces.
  76. config.filter_rails_from_backtrace!
  77. # arbitrary gems may also be filtered via:
  78. # config.filter_gems_from_backtrace("gem name")
  79. end