[Rails] Re: Problems testing a destroy failure
On Monday, January 6, 2014 6:16:48 PM UTC, Ruby-Forum.com User wrote:
> That was my original attempt too but the require_user_payment_info
>
> before_filter method checks for a valid payment_info object and will
>
> redirect away from the delete method if the @payment_info object isn't
>
> valid. If I mock the @payment_info object to be invalid, it won't
>
> make it to the delete method.
>
>
In which case you want to just stub out the destroy method. In rspec for example you could do
PaymentInfo.any_instance.should_receive(:destroy).and_return(false)
And mocha can do something similar.
Fred
>
> I must admit my mocking knowledge isn't very strong so my attempts at
>
> mocking have been failures.
>
>
>
> Here's the before_filter configuration for require_user_payment_info:
>
>
>
> before_filter :require_user_payment_info, :only => [:show, :edit,
>
> :update, :delete]
>
>
>
> --
>
> Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0245fb6d-0310-44fd-beb8-d177644b2e38%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home