I have association extension, just like in http://guides.rubyonrails.org/association_basics.html#association-extensions
Inside extension I define method has_something?
And then in specs:
# it works for me
# It raises NoMethodError: undefined method `has_something?' for :Array
This belongs in rspec-expectations. Would you kindly re-post there?
BTW I tried this myself w/ the following code and both examples pass. Please include the code if you repost to rspec-expectations.
describe Customer do
class Customer < ActiveRecord::Base
has_many :orders do
Here's an explanation for the source of the issue.
The right solution is to use the new expect syntax, since that avoids the problem entirely. However, I wonder if we should add the following to rspec-rails:
RSpec.configure do |config|
config.expect_with :rspec do |c|
This would make should work for this case (although, I think we should encourage people to use expect to avoid this issue).
Reopening since it actually belongs here, after all.
We should make the change and encourage ppl to use expect.
A better fix for CollectionProxy#should.
- Delay the fix so that users can configure a different expectation framework.
- Handle the right class for rails 3.0 (AssociationProxy) and 3.1+ (CollectionProxy).
- Fixes #588.
- Fixes #445.