So I was actually writing some tests with rspec and rails and they were failing, and I'm not expert at either rspec or rails and so a lot of things seem like "magic", ie get :index and suddenly a response variable shows up.
Anyway, I was testing a :post command and it should have been rendering a page after that. I was trying to test the page rendered after the post.
response.should have_selector("form", :method => "post") do |form| form.should have_selector("div", :class => "actions") do |div| div.should have_selector("input", :value => "Create") end end
And it just wasn't working, I was testing for information in the rendered page and it just wasn't there. I dumped the response variable (puts response.inspect) and there was a lot of info there but clearly not the page I was expecting. Then I dumped the header or head or something, can't remember and it clearly showed text that I was going to save but didn't, sorry, that said it was redirecting me. Ahh! The answer, the post throws me to a redirect and I'm testing that page, it all makes sense! So now I'm testing that the redirect is going to the right spot and the other pages are tested a different way.
response.should redirect_to(subscribe_listing_purchases_path(Listing.last))
The end.
No comments:
Post a Comment