Test units now loading


Im getting this error when running a simple unit test from the book im
learning. I have even copy pasted the code and am not sure why this is
not working

the error is
  1) Error:
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you
really wanted the id of nil, use object_id
    product_test.rb:63:in `test_read_with_fixture_variable'

My YAML file is
  id: 1
  title: Pragmatic Version Control
  description: How to use version control
  image_url: http://…/sk_svn_small.jpg
  price: 29.95
  date_available: 2005-01-26 00:00:00

My test unit is

class ProductTest < Test::Unit::TestCase
  fixtures :products

  def setup
    @product = Product.find(1)

def test_read_with_fixture_variable
    assert_kind_of Product, @product
    assert_equal @version_control_book.id, @product.id
    assert_equal @version_control_book.title, @product.title
    assert_equal @version_control_book.description, @product.description
    assert_equal @version_control_book.image_url, @product.image_url
    assert_equal @version_control_book.price, @product.price
    assert_equal @version_control_book.date_available,

Ive checked the value of @product.id and it seems its correctly getting
extracted from the database but im not sure why the instance variable
@version_control_book is not getting loaded.

Thanks heaps

EXCELLENT! It worked :slight_smile: