10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button
Once again, get the tests working, and add tests for the smarter cart.
See that the tests fail.
rake test
Run options: --seed 53025
# Running tests:
.....
Finished tests in 0.423475s, 11.8071 tests/s, 54.3125 assertions/s.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Run options: --seed 13394
# Running tests:
.......E..............
Finished tests in 1.074282s, 20.4788 tests/s, 38.1650 assertions/s.
1) Error:
test_should_create_line_item(LineItemsControllerTest):
ActiveRecord::RecordNotFound: Couldn't find Product without an ID
app/controllers/line_items_controller.rb:35:in `create'
test/controllers/line_items_controller_test.rb:21:in `block (2 levels) in <class:LineItemsControllerTest>'
test/controllers/line_items_controller_test.rb:20:in `block in <class:LineItemsControllerTest>'
22 tests, 41 assertions, 0 failures, 1 errors, 0 skips
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [ruby -I"lib:test" -I"/home/rubys/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.3/lib" "/home/rubys/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.3/lib/rake/rake_test_loader.rb" "test/{controllers,mailers,functional}/**/*_test.rb" ]>
Update parameters passed as well as expected target of redirect
edit test/controllers/line_items_controller_test.rb
test "should create line_item" do
assert_difference('LineItem.count') do
post :create, product_id: products(:ruby).id
end
assert_redirected_to cart_path(assigns(:line_item).cart)
end
rake test
Run options: --seed 45405
# Running tests:
.....
Finished tests in 0.332569s, 15.0345 tests/s, 69.1586 assertions/s.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Run options: --seed 30284
# Running tests:
......................
Finished tests in 1.578442s, 13.9378 tests/s, 27.8756 assertions/s.
22 tests, 44 assertions, 0 failures, 0 errors, 0 skips
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button