我正在将Rails 6与Grape一起使用,我不知道为什么我的规格无缘无故开始返回此类错误
An error occurred while loading ./spec/controllers/health_check_spec.rb.
Failure/Error: require File.expand_path('../config/environment', __dir__)
ActiveSupport::MessageEncryptor::InvalidMessage:
ActiveSupport::MessageEncryptor::InvalidMessage
哪个超级奇怪,因为我以前没有这样的问题。我添加了devise
和shoulda-matchers gem
,但是即使没有这些gem,我也会遇到相同的错误。
spec_helper:
require 'simplecov'
SimpleCov.start
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.default_formatter = 'doc' if config.files_to_run.one?
config.shared_context_metadata_behavior = :apply_to_host_groups
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
end
rails_helper:
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end