Rspec + Shoulda + FactoryGirl = неопределенный метод `reflect_on_association'

У меня есть Rspec + Shoulda + FactoryGirl, и я получаю следующую ошибку при попытке вызвать методы have_many или own_to для Shoulda. Все методы Shoulda, используемые в группе «валидации», работают нормально:

>   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

person obiwanchinobi    schedule 24.02.2010    source источник


Ответы (1)


Спасибо Дэвиду К. за указание на то, что должно было быть очевидным. У меня был избыточный плагин active_matchers, который конфликтовал с shoulda.

person obiwanchinobi    schedule 25.02.2010
comment
Вероятно, он говорит об этом ruby-forum.com/topic/204841. - person jipiboily; 03.04.2015