ruby on rails - how do you stub/expect a state_machine event? -


i want this:

@vehicle.should_receive(:park) @vehicle.stub!(:park) vehicle.any_instance.stub(:park) # etc. 

so can validate interaction or use state_machine in other specs without overhead of changing states...

how accomplish this?

use of above methods wrote about. note, think in versions of rspec, stubbing directly, or #should_receive replace body of said stubbed method. if later test side effects, won't present.

usually work around with.

@vehicle.should_receive(:park)    @vehicle.state = :parked end  expect   @person.exit_vehicle end.should change(@vehicle.state).from(:driving).to(:parked) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -