I'm having a hard time figuring out how to spec the BadRequest error
raised when an update action goes awry. The controller code looks
like:
def update
@product = Product.get(params[:id])
raise NotFound unless @product
if @product.update_attributes(params[:product]) || [EMAIL PROTECTED]
redirect url(:product, @product)
else
raise BadRequest
end
end
But, this is what I've come up with so far for a spec (which doesn't
work):
describe "failed update" do
it "should not be successful" do
controller = dispatch_to(Products, :update) do |c|
@product.should_receive(:update_attributes).and_return(false)
c.should raise_error(Merb::ControllerExceptions::BadRequest)
end
end
end
Merb-Auth, uses a technique like the following, but this also isn't
working for me:
describe "failed update" do
it "should not be successful" do
lambda{
dispatch_to(Products, :update) do |c|
@product.should_receive(:update_attributes).and_return(false)
end
}.should raise_error(Merb::ControllerExceptions::BadRequest)
end
end
How do you guys go about spec-ing this case?
Elliot
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---