I’m trying to write a test like the one at the bottom of page 148 in
Agile Rails.
I’m using rails 1.0
I’ve created the fixture correctly I’m pretty sure because the test
database table is being populated per the fixture.
I have what I think is a simple unit test:
require File.dirname(FILE) + ‘/…/test_helper’
class CaseTest < Test::Unit::TestCase
fixtures :cases
def setup
@case = Case.find(1)
end
Replace this with your real tests.
def test_verify_schema_has_correct_fields
assert_kind_of Case, @case
assert_equal 1, @case.id
assert_equal “F-06-101”, @case.case_number
assert_equal @first.case_number, @case.case_number
end
The first 2 assert_equal statements are working fine and demonstrate
the basic table logic is fine and that my fixture is working.
The third one is failing because @first is nil.
Per the book @first should be automatically created because it is the
name of my fixture. (ie. the scaffold named the first fixture “first”
and I should be able to reference it as @first.)
Any idea what is wrong?
Greg
Greg F.
The Norcross Group
Forensics for the 21st Century