On Rails 2.3.2 I'm trying to test a view in a functional test
def test_view
get :form
xhr :post, :add_to_cart, {:id => 1}
post :create, {:param => value}
assert_select 'title', 'Success!'
end
But keep getting a failure:
Expected at least 1 element matching "title", found 0. is not true.
I understand that you cannot use 'assert_select' after a xhr call, but in this case, I'm doing it AFTER a regular post request.
If I drop the xhr request
def test_view
get :form
post :create, {:param => value}
assert_select 'title', 'Success!'
end
Then it works like charm. I could set the cart (which I store in session) manually, but then I would not be really testing the view...
Any ideas?
I think you've already figured it out -- functional tests expect a single controller action, not multiple actions. I'd suggest replacing this with an integration test.