Skip to content

Instantly share code, notes, and snippets.

Created December 17, 2009 10:29
Show Gist options
  • Save anonymous/258674 to your computer and use it in GitHub Desktop.
Save anonymous/258674 to your computer and use it in GitHub Desktop.
context "failure due to record invalid" do
before(:each) do
e = mock("errors", :null_object => true)
e.stub!(:full_messages).and_return([])
@obj.stub!(:errors).and_return(e)
@obj.stub!('update_attributes!').and_raise(ActiveRecord::RecordInvalid.new(@obj))
put :update, { :id => @obj.id, at_name => @invalid_update }
end
it "should flash an error" do
flash[:error].should_not be_nil
end
it "should render the edit view with status 400" do
response.should render_template('edit')
response.code.should == '400'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment