diff options
Diffstat (limited to 'railties/guides/source/testing.textile')
-rw-r--r-- | railties/guides/source/testing.textile | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 2341a3522c..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: <ruby> -# 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 -</ruby> - -Fixtures can also transform themselves into the form of the original class. Thus, you can get at the methods only available to that class. - -<ruby> -# 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) </ruby> @@ -738,7 +731,6 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai |+rake test:benchmark+ |Benchmark the performance tests| |+rake test:functionals+ |Runs all the functional tests from +test/functional+| |+rake test:integration+ |Runs all the integration tests from +test/integration+| -|+rake test:plugins+ |Run all the plugin tests from +vendor/plugins/*/**/test+ (or specify with +PLUGIN=_name_+)| |+rake test:profile+ |Profile the performance tests| |+rake test:recent+ |Tests recent changes| |+rake test:uncommitted+ |Runs all the tests which are uncommitted. Supports Subversion and Git| @@ -927,7 +919,7 @@ class UserControllerTest < ActionController::TestCase assert_difference 'ActionMailer::Base.deliveries.size', +1 do post :invite_friend, :email => 'friend@example.com' end - invite_email = ActionMailer::Base.deliveries.first + invite_email = ActionMailer::Base.deliveries.last assert_equal "You have been invited by me@example.com", invite_email.subject assert_equal 'friend@example.com', invite_email.to[0] |