When I run the unit testing code in Unit Testing Models chapter of the Agile
Rails book, I get the
following error:
$ ruby test/unit/cart_test.rb
Loaded suite test/unit/cart_test
Started
F.
Finished in 0.21806 seconds.
1) Failure:
test_add_duplicate_product(CartTest) [test/unit/cart_test.rb:22]:
<4690> expected but was
<3579>.
2 tests, 3 assertions, 1 failures, 0 errors
require File.dirname(__FILE__) + ''/../test_helper''
class CartTest < Test::Unit::TestCase
fixtures :products
def setup
@cart = Cart.new
@rails = products(:rails_book)
@ruby = products(:ruby_book)
end
def test_add_unique_products
@cart.add_product @rails
@cart.add_product @ruby
assert_equal 2, @cart.items.size
assert_equal @rails.price + @ruby.price, @cart.total_price
end
def test_add_duplicate_product
@cart.add_product @rails
@cart.add_product @ruby
assert_equal 2*@rails.price, @cart.total_price
assert_equal 1, @cart.items.size
assert_equal 2, @cart.items[0].quantity
end
end
Could someone please tell me why I am getting this error? TIA
http://www.ProblemSolvingSkill.net
Hone your problem-solving skills