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.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
ProductTest:
PASS image url (0.33s)
PASS product attributes must not be empty (0.01s)
PASS product is not valid without a unique title (0.01s)
PASS product is not valid without a unique title - i18n (0.00s)
PASS product price must be positive (0.01s)
Finished in 0.407320 seconds.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
CartsControllerTest:
PASS should create cart (0.32s)
PASS should destroy cart (0.13s)
PASS should get edit (0.13s)
PASS should get index (0.01s)
PASS should get new (0.05s)
PASS should show cart (0.01s)
PASS should update cart (0.01s)
LineItemsControllerTest:
ERROR should create line item (0.02s)
ActiveRecord::RecordNotFound: Couldn't find Product without an ID
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:308:in `find_with_ids'
PASS should destroy line item (0.01s)
PASS should get edit (0.02s)
PASS should get index (0.01s)
PASS should get new (0.01s)
PASS should show line item (0.01s)
PASS should update line item (0.01s)
ProductsControllerTest:
PASS should create product (0.11s)
PASS should destroy product (0.01s)
PASS should get edit (0.02s)
PASS should get index (0.10s)
PASS should get new (0.01s)
PASS should show product (0.01s)
PASS should update product (0.02s)
StoreControllerTest:
PASS should get index (0.16s)
Finished in 1.219384 seconds.
22 tests, 33 assertions, 0 failures, 1 errors, 0 skips
Errors running test:functionals!
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.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
ProductTest:
PASS image url (0.36s)
PASS product attributes must not be empty (0.01s)
PASS product is not valid without a unique title (0.01s)
PASS product is not valid without a unique title - i18n (0.00s)
PASS product price must be positive (0.01s)
Finished in 0.446170 seconds.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
CartsControllerTest:
PASS should create cart (0.29s)
PASS should destroy cart (0.19s)
PASS should get edit (0.13s)
PASS should get index (0.01s)
PASS should get new (0.01s)
PASS should show cart (0.01s)
PASS should update cart (0.01s)
LineItemsControllerTest:
PASS should create line item (0.09s)
PASS should destroy line item (0.01s)
PASS should get edit (0.02s)
PASS should get index (0.01s)
PASS should get new (0.01s)
PASS should show line item (0.01s)
PASS should update line item (0.02s)
ProductsControllerTest:
PASS should create product (0.10s)
PASS should destroy product (0.01s)
PASS should get edit (0.02s)
PASS should get index (0.09s)
PASS should get new (0.01s)
PASS should show product (0.01s)
PASS should update product (0.02s)
StoreControllerTest:
PASS should get index (0.14s)
Finished in 1.260513 seconds.
22 tests, 35 assertions, 0 failures, 0 errors, 0 skips
10.1 Iteration E1: Creating a Smarter Cart 9.3 Iteration D3: Adding a button