I'd just look at the controller.status.
A lot of this will be pretty locked down by 1.0, if I get a chance to merge
in my testing stuff in the next few days.

-- Yehuda

On Fri, Sep 26, 2008 at 2:54 PM, LinPan <[EMAIL PROTECTED]> wrote:

>
> 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
>
> >
>


-- 
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to