Skip to content

Instantly share code, notes, and snippets.

@bjensen
Forked from anonymous/gist:258674
Created December 23, 2009 14:43
Show Gist options
  • Save bjensen/262553 to your computer and use it in GitHub Desktop.
Save bjensen/262553 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