[Rails] Re: Problems testing a destroy failure
Bingo - that totally worked and here's my solution:
[code]
def test_unsuccessful_delete
payment_info = Factory.create(:payment_info, :user_guid=>@user.guid,
:card_expires_month=>'04',
:card_expires_year=>(Date.today.year+2).to_s,
:cardholder_city=>"test city",
:cardholder_state=>'NC',
:cardholder_country=>'US', :cardholder_zip=>'27612')
PaymentInfo.any_instance.stubs(:destroy).returns(false)
delete(:delete, {}, @session)
assert_response(:redirect)
assert_equal false, assigns(:payment_info).blank?
assert_redirected_to({:controller=>'account', :action=>'edit'})
assert_equal flash[:error], "There was an error deleting your credit
card information. Please try again."
end
[/code]
Thanks for your help!
--
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/e8b9037c2d0089bf0a3294a876189888%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home