Hello All,
I am experiencing the following test unit error working with Rails that
I can’t fathom.
I have a products.yml file which holds the following test fixture for
the products table:
dell_pc:
id: 1
title: Dell PC
description: Dell PC
image_url: http://…/pc_image.jpg
price: 15000.00
date_available: 2005-12-31 06:53:00
I also have the following product_test.rb file to test the fixture
above:
require File.dirname(FILE) + ‘/…/test_helper’
class ProductTest < Test::Unit::TestCase
fixtures :products
def setup
@product = Product.find(1)
end
def test_fixtures
assert_kind_of Product, @product
assert_equal 1, @product.id
assert_equal “Dell PC”, @product.title
assert_equal “Dell PC”, @product.description
assert_equal “http://…/pc_image.jpg”, @product.image_url
puts “class of @product.price = #{@product.price.class}”
puts “value of @product.price = #{@product.price}”
assert_equal 15000.00, @product.price
assert_equal “2005-12-31 06:53:00”,
@product.date_available_before_type_cast
end
end
When I run ruby test/unit/product_test.rb I receive the following
results:
Loaded suite test/unit/product_test
Started
class of @product.price = Float
value of @product.price = 15000.0
F
Finished in 5.485 seconds.
- Failure:
test_fixtures(ProductTest) [test/unit/product_test.rb:18]:
<15000.0> expected but was
<15000.0>.
1 tests, 6 assertions, 1 failures, 0 errors
Does anyone have any suggestions on how to resolve this issue?
Many thanks,
Bruce.