From: Mike Blyth Date: 2006-03-18T02:24:10+09:00 Subject: Named fixtures and automatic instance variables; newbie prob According to Agile Web Development with Rails (pg 148), a fixture like version_control_book: id: 1 title: Pragmatic Version Control ... loaded as "fixtures: products" can be accessed as @products["version_control_book"] or @version_control_book within a unit test (TestCase). My (very simple) tests are working otherwise, but the equivalents of @products and @version_control_book are nil. Why? patients.yml is: ------------------------- newborn: id: 1 hosp_ident: 120001010 last_name: Musa other_names: BabyA sex: F .... etc. ----------------------- patients_test.rb is ----------------------------- require File.dirname(__FILE__) + '/../test_helper' class PatientTest < Test::Unit::TestCase fixtures :patients def setup @patient = Patient.find(1) end def test_truth puts "@patients = #{@patients.inspect}" puts "@newborn = #{@newborn}" assert_kind_of Patient, @patient assert_equal 1, @patient.id assert_equal 'F', @patient.sex assert_equal '-', @patient.rv ... etc end end ------------------------------------ and the output is: [mike@eeyore ptbase]$ ruby test/unit/patient_test.rb Loaded suite test/unit/patient_test Started nil . Finished in 0.166667 seconds. 1 tests, 4 assertions, 0 failures, 0 errors [mike@eeyore ptbase]$ ruby test/unit/patient_test.rb Loaded suite test/unit/patient_test Started @patients = nil @newborn = . Finished in 0.134237 seconds. 1 tests, 4 assertions, 0 failures, 0 errors -- Posted via http://www.ruby-forum.com/.