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
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.....
Finished in 0.316023 seconds.
5 tests, 23 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.......E..............
Finished in 0.940112 seconds.
1) Error:
test_should_create_line_item(LineItemsControllerTest):
ActiveRecord::RecordNotFound: Couldn't find Product without an ID
app/controllers/line_items_controller.rb:46:in `create'
test/functional/line_items_controller_test.rb:21:in `test_should_create_line_item'
test/functional/line_items_controller_test.rb:20:in `test_should_create_line_item'
22 tests, 33 assertions, 0 failures, 1 errors
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [/home/rubys/.rvm/rubies/ruby-1.8.7-p352/bi...]>
Update parameters passed as well as expected target of redirect
edit test/functional/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
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.....
Finished in 0.443183 seconds.
5 tests, 23 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
......................
Finished in 1.148496 seconds.
22 tests, 35 assertions, 0 failures, 0 errors
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button