Forum: RSpec Rspec + Shoulda + FactoryGirl = undefined method `reflect_on_association'

Posted by obiwan chinobi (dmht81)
on 2010-02-24 15:12
(Received via mailing list)
I have Rspec + Shoulda + FactoryGirl and I am receiving the following
error when attempting to call Shoulda's have_many or belong_to
methods. All Shoulda methods used in the "validations" group work
fine:

    >   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:

Thanks in advance

spec/spec_helper.rb
==================================================================

    require 'shoulda'

spec/models/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
Posted by David Chelimsky (Guest)
on 2010-02-24 15:27
(Received via mailing list)
On Wed, Feb 24, 2010 at 2:23 AM, Dave <david.mh.tong@gmail.com> wrote:
>    >   specify { object.should matcher }
>    > 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

What's active_matchers? I don't think that's part of rspec, shoulda,
or factory_girl.
Posted by obiwan chinobi (dmht81)
on 2010-02-25 14:03
(Received via mailing list)
Thank you so much. I have been staring at this for way too long and
missed the obvious. I had a redundant active_matchers plugin that was
conflicting with shoulda.

Cheers,
Dave
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.