Re: [rspec-users] Stub an AR Model Instance Method

2011-06-19 Thread J. B. Rainsberger
On Sat, Jun 18, 2011 at 21:10, Karl wrote: > 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(:a

Re: [rspec-users] Stub an AR Model Instance Method

2011-06-18 Thread Karl
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

Re: [rspec-users] Stub an AR Model Instance Method

2011-06-12 Thread David Chelimsky
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

Re: [rspec-users] Stub an AR Model Instance Method

2011-06-11 Thread J. B. Rainsberger
On Thu, Jun 9, 2011 at 14:33, 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_

[rspec-users] Stub an AR Model Instance Method

2011-06-11 Thread Karl
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) I know I could use '