small medium large xlarge

08 Nov 2013, 01:51
Tony Kyle (6 posts)


First post, new RoR developer though I have 20 years of experience with other tools and the like. Searching the forum did not turn up this specific question.

Working my way through the book and came across this one issue I cannot resolve:

Finished tests in 0.535075s, 41.1157 tests/s, 82.2315 assertions/s.

1) Failure: CartsControllerTest#test_should_destroy_cart [/Users/tkyle/Source/RoR/depot/test/controllers/carts_controller_test.rb:48]: Expected response to be a redirect to but was a redirect to Expected “” to be === “”.

I’ve even tried looking at the code available via download and it does not resolve the 1 failure.

The code for the carts_controller is the same between what I’ve typed from the book and from the downloaded file.

Anyone have thoughts about how to resolve this unit test failure?

08 Nov 2013, 01:58
Tony Kyle (6 posts)

Just answered my own question.

The code in the book for the carts_controller_test is wrong. Instead of store_url or store_path we need to “assert_redirected_to carts_path” and the test completes correctly. Even “carts_url” works.

What is frustrating is the downloaded code for the Rails 4 version has the wrong object. It would seem the code was not unit tested itself prior to being published.

08 Nov 2013, 19:35
Colin Williams (9 posts)

I didn’t think we were supposed to test the controller, but the carts model itself…

09 Nov 2013, 00:13
Tony Kyle (6 posts)

Hi, it was the code in the book that led me astray. Hence I’m calling it out so other people will not get detoured when the unit tests reports a failure.

You must be logged in to comment