What does :save => true mean in mock_model?

@weather = mock_model(Weather, :id => “1”)
@forecast = mock_model(Forecast, :weather => @weather, :save => true)

what’s the different between with :save => true or without it?

On Sat, Jun 27, 2009 at 9:55 AM, Zhenning G.[email protected]
wrote:

@weather = mock_model(Weather, :id => “1”)
@forecast = mock_model(Forecast, :weather => @weather, :save => true)

what’s the different between with :save => true or without it?

The hash submitted to mock_model sets up method stubs:

@weather.save
=> MockExpectationError “received unexpected message ‘save’”
@forecast.save
=> true

HTH,
David

David C. wrote:

clear, thank you David

one more question.
Forecast.stub!(:new).and_return(@forecast)
Forecast.should_receive(:new).with(anything()).and_return(@forecast)

what’s the different between stub! and should_receive ?

On Sat, Jun 27, 2009 at 10:55 AM, Zhenning G.[email protected]
wrote:

one more question.
Forecast.stub!(:new).and_return(@forecast)
Forecast.should_receive(:new).with(anything()).and_return(@forecast)

what’s the different between stub! and should_receive ?

Read this: http://rspec.info/documentation/mocks/ and then feel free
to ask questions about anything you don’t understand.

Cheers,
David