2
Shspa의 have_many 또는 belongs_to 메서드를 호출 할 때 Rspec + Shoulda + FactoryGirl이 있는데 다음과 같은 오류가 발생합니다. 벌금 "검증"그룹 활동에 사용 된 모든 진작 방법 : 사전에Rspec + Shoulda + FactoryGirl = 정의되지 않은 메서드 'reflect_on_association'
> NoMethodError in 'A Project
> associations should When you call a
> matcher in an example without a
> String, like this:
>
> specify { object.should matcher }
>
> or this:
>
> it { should matcher }
>
> RSpec expects the matcher to have a
> #description method. You should either add a String to the example this
> matcher is being used in, or give it a
> description method. Then you won't
> have to suffer this lengthy warning
> again. ' undefined method
> `reflect_on_association' for
> #<Project:0x34d8624> /vendor/plugins/active_matchers/lib/matchers/association_matcher.rb:37:in
> `confirm_association'
> /vendor/plugins/active_matchers/lib/matchers/association_matcher.rb:36:in
> `each'
> /vendor/plugins/active_matchers/lib/matchers/association_matcher.rb:36:in
> `confirm_association'
> /vendor/plugins/active_matchers/lib/matchers/association_matcher.rb:11:in
> `matches?'
> ./spec/models/project_spec.rb:7:
감사
사양/spec_helper.rb
require 'shoulda'
사양/모델/project_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'
describe "A Project" do
describe "associations" do
subject { Factory(:project) }
it { should have_many(:tasks) }
it { should belong_to(:project_status) }
end
describe "validations" do
subject { Factory(:project) }
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name).case_insensitive }
it { should allow_mass_assignment_of(:name) }
end
end
누가 David C입니까? 그는 무엇을 지적 했습니까? – Esko
그는 아마도이 https://www.ruby-forum.com/topic/204841에 대해 이야기하고있을 것입니다. – jipiboily