Forum: Ruby on Rails Fixture access question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2b4ac2c411822a657bc7cd3da8637326?d=identicon&s=25 Tony Ketteringham (Guest)
on 2006-02-08 04:52
(Received via mailing list)
Hi,
I want to add the basic model record create tests for my rails app
as in the "Agile Web Development with Rails" example:
i.e. (header stuff and boring repitition missed)

def test_create
  assert_kind_of Requirement, requirements(:requirement_1)
  assert_equal <at>requirements["requirement_1"]["name"],
requirements(:requirement_1).name
end

Now I'm not supposed to use <at>requirements since that's slow but
how do I now "get" to the Fixture values, as opposed to the
Requirement class object created from those values?
I thought that requirements(:requirement_1)["created_on"]
would be the go but it worries me that:
requirements(:requirement_1).class is "Requirement"
and (when I turn it back on)
@requirements["requirement_1"].class is "Fixture"

This is probably post Java programming paranoia but I'd
hate to write a bunch of tests validating that a=a :-)
I've had a read of the fixtures questions on the rails list, had a read
of
the HowtoUnitTest, read MikeClark's Weblog but no-one seems
to do exactly this. I'm afraid my Ruby isn't yet up to working this out
from
fixtures.rb (though I've had an interesting read)
Thanks in advance for any help.
Regards,
Tony
This topic is locked and can not be replied to.