Topic: Unit Test does not Generate Instance Variables from YML
I am coding my first unit tests. I expected instance variables to be created for each instance named record in my test fixture, but it doesn't seem to be happening. (I'm running Ruby 1.8.2, RoR 1.1.6 should that be relevant.
This is what's in publications.yml:
And this is one of my unit tests:
require File.dirname(__FILE__) + '/../test_helper'
class PublicationTest < Test::Unit::TestCase
@pub = Publication.find(1)
# Replace this with your real tests.
assert_kind_of Publication, @pub
assert_equal publications("pub_single_ed").name, @pub.name
assert_equal @pub_single_ed.name, @pub.name # <<<< This line causes an error
What I thought would happen is that I could either use the syntax publications("pub_single_ed").name or @pub_single_ed.name to refer to the values in the fixture definition. The line with the instance variable syntax generates an error.
NoMethodError: You have a nil object when you didn't expect it!
The error occured while evaluating nil.name
Was this feature eliminated in some version somewhere along the way, or do I need to do something special to enable it. Thanks.