Forum: RSpec ActiveRecord::Base.should_receive(:find) fails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
95a6493586dcb150d4fb4aec8f81b766?d=identicon&s=25 Tero Tilus (Guest)
on 2009-02-19 19:47
(Received via mailing list)
I've got an AR-model with some find-magic I want to test.  When I have

  ActiveRecord::Base.should_receive(:find).with(anything(),assert_options)
  MyModel.find(:all,find_options)

in my example find-method somehow disappears alltogether and I get

  NoMethodError in 'MyModel find-options are passed on correctly'
  undefined method `find' for MyModel

And docs tell that (at least something really close to that one)
should work

  http://rspec.info/documentation/mocks/partial_mocks.html
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-02-19 19:54
(Received via mailing list)
On Thu, Feb 19, 2009 at 12:34 PM, Tero Tilus <tero@tilus.net> wrote:
> I've got an AR-model with some find-magic I want to test.  When I have
>
>  ActiveRecord::Base.should_receive(:find).with(anything(),assert_options)
>  MyModel.find(:all,find_options)

MyModel != ActiveRecord::Base

Try this

MyModel.should_receive(:find).with(anything(),assert_options)
MyModel.find(:all,find_options)
This topic is locked and can not be replied to.