:
spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'shoulda/matchers'
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.shared_context_metadata_behavior = :apply_to_host_groups
config.include RSpec::RequestDescriber, type: :request
config.before :all do
FactoryGirl.factories.clear
FactoryGirl.reload
end
config.before :suite do
DatabaseRewinder.clean_all
end
config.after :each do
DatabaseRewinder.clean
end
Autodoc.configuration.toc = true
end
rails_helper.rb
RSpec.configure do |config|
config.include RSpec::RequestDescriber, type: :request
# config.include RequestHelpers, type: :request
# config.include RequestMacros, type: :request
config.before :all do
FactoryGirl.factories.clear
FactoryGirl.find_definitions
FactoryGirl.reload
end
config.before :suite do
DatabaseRewinder.clean_all
end
config.after :each do
DatabaseRewinder.clean
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
end
はここでスペックコードです。
type: :model
をスペックコードに追加する必要がありました。作業溶液は次のとおりです。
describe UserEventFavorite, type: :model do
let(:user_event_favorite) { FactoryGirl.build :user_event_favorite }
subject { user_event_favorite }
it { should respond_to :user_id }
it { should respond_to :event_id }
it { should belong_to :user }
it { should belong_to :event }
end
代わりの
describe UserEventFavorite do
let(:user_event_favorite) { FactoryGirl.build :user_event_favorite }
subject { user_event_favorite }
it { should respond_to :user_id }
it { should respond_to :event_id }
it { should belong_to :user }
it { should belong_to :event }
end
あなたは、スペックコードをしてください追加することはできますか? –
私の悪い!ただ追加されました。 – alpaca
スペルファイルに 'rails_helper''が必要なことを忘れてしまったのでしょうか? –