Why does this test fail.

34 views
Skip to first unread message

Roelof Wobben

unread,
Dec 7, 2014, 12:50:57 PM12/7/14
to rubyonra...@googlegroups.com
Hello,

Sorry for the double post but on reddit nobody seems to have the solution.

im following the agile web developement book but then with my own layout.

Now am at chapter 9 where a shopping card is added. But as soon as I try to test the card I see this error

LineItemsControllerTest#test_should_create_line_item:
RuntimeError: @controller is nil: make sure you set it in your test's setup method.

my code can be found here : https://github.com/roelof1967/commerce-try

Who can help me figure out why this test is failing. According to the book it must all be successfull.

Roelof


André Orvalho

unread,
Dec 8, 2014, 5:26:20 AM12/8/14
to rubyonra...@googlegroups.com
Normally that problem occurs when you have a weird nesting or the naming of the controller compared to the test name is not correct as you can see in this 2 posts:

I only use rspec so I am not sure that this:

has the correct syntax. does the test for delete at the end fail too?

Matt Jones

unread,
Dec 8, 2014, 6:42:14 AM12/8/14
to rubyonra...@googlegroups.com
The file in app/controllers/concerns is not named correctly - it declares a `CurrentCart` module, but is named `current_card.rb`. Fixing that makes all the tests pass.

--Matt Jones 

Roelof Wobben

unread,
Dec 8, 2014, 8:13:13 AM12/8/14
to rubyonra...@googlegroups.com


Op maandag 8 december 2014 12:42:14 UTC+1 schreef Matt Jones:
I found it . The problem was in the name. When I change it to current_cart.rb it worked fine.

Roelof
 
Reply all
Reply to author
Forward
0 new messages