Found my problem... mostly due to my misunderstanding of mocks. Joe's
suggestion above led me down the right path. This worked:

@account = mock_model(Account)
@account.stub!(:next_serial_number).and_return(43, nil)
Widget.any_instance.stub(:account).and_return(@account)


On Jun 12, 5:33 am, David Chelimsky <dchelim...@gmail.com> wrote:
> On Jun 9, 2011, at 12:33 PM, Karl wrote:
>
> > Obviously, I'm missing something very simple, can someone please
> > explain how to stub an instance of an AR model method.
>
> > This does not work:
> > @widget = Widget.first # Widget has an instance method called 
> > 'next_seriel_number'
> > @widget.stub(:next_serial_number).and_return(43, nil)
>
> "This does not work:" doesn't tell us what the problem is. Please be 
> specific. Are you getting a failure? If so, please show us the complete code 
> for the example, including any before hooks, and the failure message you're 
> getting.
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to