Hi,
I’m trying to use a variable fixture test (like the Rails book page 148)
I am getting the following error.
- Error:
test_read(ProductTest):
RuntimeError: Called id for nil, which would mistakenly be 4 – if you
really wanted the id of nil, use object_id
test/unit/product_test.rb:13:in `test_read’
What am I doing wrong?
Thanks,
Peter
########## product_test.rb ##############
class ProductTest < Test::Unit::TestCase
fixtures :products
def setup
@product = Product.find(2)
end
def test_read
assert_kind_of Product, @product
assert_equal 2, @product.id http://product.id
next line causes the error
assert_equal @alpha.id http://alpha.id, @product.id
http://product.id
end
end
########## products.yml ###############
gamma:
id: 1
name: gamma
alpha:
id: 2
name: alpha
beta:
id: 3
name: beta