Just starting out in using Test::Unit
but having a problem nailing down a redirect test:
test "should destroy line_item" do
assert_difference('LineItem.count', -1) do
delete :destroy, id: @line_item
end
assert_redirected_to controller: 'carts', action: 'show'
end
which throws the following error:
Failure: Expected response to be a redirect to <http://test.host/carts/980190962> but was a redirect to <http://test.host/carts/980190963>.
test_should_destroy_line_item(LineItemsControllerTest)
test/functional/line_items_controller_test.rb:47:in `block in <class:LineItemsControllerTest>'
The docs state the following:
assert_redirected_to(options = {}, message=nil) public
Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that assert_redirected_to(:controller => "weblog") will also match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on.
but assert_redirected_to controller: 'carts'
leads to an even more outright failure:
Failure: Expected response to be a redirect to <http://test.host/carts> but was a redirect to <http://test.host/carts/980190963>.
test_should_destroy_line_item(LineItemsControllerTest)
If the documentation is correct, what am I missing? If it is not, what alternatives do I have to test the redirect regardless of a matching id?