Rspecを使ってrailsのテストを行っているのですがエラーが起きてしまいました。私はRspec初心者のためこのエラーがなんだかわかりません。教えてくれると幸いです。
error
1An error occurred while loading rails_helper. 2Failure/Error: config.inculde FactoryBot::Syntax::Methods 3 4NoMethodError: 5 undefined method `inculde' for #<RSpec::Core::Configuration:0x00000248e501abc8> 6 Did you mean? include 7# ./spec/rails_helper.rb:24:in `block in <top (required)>' 8# ./spec/rails_helper.rb:16:in `<top (required)>' 9No examples found. 10No examples found. 11inished in 0.00025 seconds (files took 10.87 seconds to load) 120 examples, 0 failures, 1 error occurred outside of examples 13 14Finished in 0.00025 seconds (files took 10.87 seconds to load) 150 examples, 0 failures, 1 error occurred outside of examples 16
rails_healper.rbとspec_healper.rbを書きます。
rails_healper.rb
1require 'spec_helper' 2ENV['RAILS_ENV'] ||= 'test' 3require File.expand_path('../../config/environment', __FILE__) 4abort("The Rails environment is running in production mode!") if Rails.env.production? 5require 'rspec/rails' 6require 'factory_bot' 7require 'faker' 8 Dir[Rails.root.join("spec/support/**/*.rb")].each { |file| require file} 9 begin 10 ActiveRecord::Migration.maintain_test_schema! 11rescue ActiveRecord::PendingMigrationError => e 12 puts e.to_s.strip 13 exit 1 14end 15 RSpec.configure do |config| 16 config.fixture_path = "#{::Rails.root}/spec/fixtures" 17 config.use_transactional_fixtures = true 18 config.infer_spec_type_from_file_location! 19 # Filter lines from Rails gems in backtraces. 20 config.filter_rails_from_backtrace! 21 # arbitrary gems may also be filtered via: 22 # config.filter_gems_from_backtrace("gem name") 23 config.inculde FactoryBot::Syntax::Methods 24end
spec_healper.rb
1RSpec.configure do |config| 2 config.expect_with :rspec do |expectations| 3 expectations.include_chain_clauses_in_custom_matcher_descriptions = true 4 end 5 config.mock_with :rspec do |mocks| 6 mocks.verify_partial_doubles = true 7 end 8 config.shared_context_metadata_behavior = :apply_to_host_groups 9end

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/05/16 02:38