From 255d9c3d6bdee9d1d1692e4044f1e7f34ae230e7 Mon Sep 17 00:00:00 2001 From: Amro Mousa Date: Sun, 5 Feb 2012 09:54:32 -0500 Subject: Update fixtures testing help --- railties/guides/source/testing.textile | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index e0386b95b4..1e6b92f45c 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -114,25 +114,18 @@ Rails by default automatically loads all fixtures from the +test/fixtures+ folde * Load the fixture data into the table * Dump the fixture data into a variable in case you want to access it directly -h5. Hashes with Special Powers +h5. Fixtures are ActiveRecord objects -Fixtures are basically Hash objects. As mentioned in point #3 above, you can access the hash object directly because it is automatically setup as a local variable of the test case. For example: +Fixtures are instances of ActiveRecord. As mentioned in point #3 above, you can access the object directly because it is automatically setup as a local variable of the test case. For example: -# this will return the Hash for the fixture named david +# this will return the User object for the fixture named david users(:david) # this will return the property for david called id users(:david).id - - -Fixtures can also transform themselves into the form of the original class. Thus, you can get at the methods only available to that class. - - -# using the find method, we grab the "real" david as a User -david = users(:david).find -# and now we have access to methods only available to a User class +# one can also access methods available on the User class email(david.girlfriend.email, david.location_tonight) -- cgit v1.2.3