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.
rails test
/home/rubys/.rvm/gems/ruby-2.4.0/gems/sass-3.4.23/lib/sass/util.rb:1109: warning: constant ::Fixnum is deprecated
Run options: --seed 51448
# Running:
.E
Error:
LineItemsControllerTest#test_should_create_line_item:
ActiveRecord::RecordNotFound: Couldn't find Product with 'id'=
app/controllers/line_items_controller.rb:35:in `create'
test/controllers/line_items_controller_test.rb:20:in `block (2 levels) in <class:LineItemsControllerTest>'
test/controllers/line_items_controller_test.rb:19:in `block in <class:LineItemsControllerTest>'
bin/rails test test/controllers/line_items_controller_test.rb:18
..........................
Finished in 0.494471s, 56.6262 runs/s, 111.2300 assertions/s.
28 runs, 55 assertions, 0 failures, 1 errors, 0 skips
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 line_items_url, params: { product_id: products(:ruby).id }
end
follow_redirect!
assert_select 'h2', 'Your Pragmatic Cart'
assert_select 'li', 'Programming Ruby 1.9'
end
Rerun the previously failing test to verify the fix.
rails test test/controllers/line_items_controller_test.rb
Run options: --seed 55751
# Running:
.......
Finished in 0.279273s, 25.0651 runs/s, 35.8073 assertions/s.
7 runs, 10 assertions, 0 failures, 0 errors, 0 skips
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button