0

When I run a file of rspec tests on my Rails application, everything passes except the tests for has_many associations:

it { should have_many(:notes) } # ERROR
it { should belong_to(:agent_field_set) } # OK
it { should have_and_belong_to_many(:profiles) } # OK

The should have_many(:notes) line raises ArgumentError: wrong number of arguments (0 for 1). I've checked my database and my model file to verify the existance of a has_many association, and both appear fine:

has_many :notes, class_name: "NoteNs::Note", foreign_key: :user_id

Can anyone tell me where to look for the problem?

Specs: Ruby 1.9.3, Rails 3.2.11

JellicleCat
  • 28,480
  • 24
  • 109
  • 162

1 Answers1

0

At long last, what fixed the problem was renaming one of my named scopes. My named scope was called parent, and my model has a belongs_to :parent association.

I can't guess why a conflict arises between a named scope, being on the class, and an association, being on an instance. +1 to anyone who can explain that one to me.

JellicleCat
  • 28,480
  • 24
  • 109
  • 162