Created
August 7, 2008 22:17
-
-
Save michael/4505 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe Machines, "#update" do | |
| before(:each) do | |
| Machine.auto_migrate! | |
| Machinemodel.auto_migrate! | |
| @machine = Machine.create(:serial_number => "FAKENUM", :machinemodel => Machinemodel.create(:name => "IR2880")) | |
| @machine.save # machine#1 | |
| @machine = Machine.create(:serial_number => "FAKENUM2", :machinemodel => Machinemodel.create(:name => "IR2200")) | |
| @machine.save # machine#2 | |
| @params_valid = { :id => @machine.id, :machine => {:serial_number => "CHANGED"} } | |
| @params_invalid = { :id => @machine.id, :machine => {:serial_number => "FAKENUM"}} | |
| @params_non_existent_id = { :id => 23432, :machine => {:serial_number => "FAKENUM"}} | |
| end | |
| it "should do something" do | |
| end | |
| it "should raise an exception when invalid param hash is submitted" do | |
| lambda { | |
| dispatch_to(Machines, :update, @params_invalid).should redirect_to("/machines") | |
| }.should raise_error(Merb::ControllerExceptions::PreconditionFailed) | |
| end | |
| it "should raise an exception when non-existing id is submitted" do | |
| lambda { | |
| dispatch_to(Machines, :update, @params_non_existent_id).should redirect_to("/machines") | |
| }.should raise_error(Merb::ControllerExceptions::NotFound) | |
| end | |
| it "should update a machine when valid param hash is submitted" do | |
| dispatch_to(Machines, :update, @params_valid).should redirect_to("/machines") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment