aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/testing.textile
diff options
context:
space:
mode:
Diffstat (limited to 'railties/guides/source/testing.textile')
-rw-r--r--railties/guides/source/testing.textile18
1 files changed, 9 insertions, 9 deletions
diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile
index 8129dc34c2..9b764806a8 100644
--- a/railties/guides/source/testing.textile
+++ b/railties/guides/source/testing.textile
@@ -201,7 +201,7 @@ This line of code is called an _assertion_. An assertion is a line of code that
Every test contains one or more assertions. Only when all the assertions are successful the test passes.
-h4. Preparing you Application for Testing
+h4. Preparing your Application for Testing
Before you can run your tests you need to ensure that the test database structure is current. For this you can use the following rake commands:
@@ -217,14 +217,14 @@ NOTE: +db:test:prepare+ will fail with an error if db/schema.rb doesn't exists.
h5. Rake Tasks for Preparing your Application for Testing
-|_.Tasks |_.Description|
+|_.Tasks |_.Description|
|+rake db:test:clone+ |Recreate the test database from the current environment's database schema|
|+rake db:test:clone_structure+ |Recreate the test databases from the development structure|
|+rake db:test:load+ |Recreate the test database from the current +schema.rb+|
|+rake db:test:prepare+ |Check for pending migrations and load the test schema|
|+rake db:test:purge+ |Empty the test database.|
-TIP: You can see all these rake tasks and their descriptions by running +rake \-\-tasks \-\-describe+
+TIP: You can see all these rake tasks and their descriptions by running +rake --tasks --describe+
h4. Running Tests
@@ -384,7 +384,7 @@ By now you've caught a glimpse of some of the assertions that are available. Ass
There are a bunch of different types of assertions you can use. Here's the complete list of assertions that ship with +test/unit+, the testing library used by Rails. The +[msg]+ parameter is an optional string message you can specify to make your test failure messages clearer. It's not required.
-|_.Assertion |_.Purpose|
+|_.Assertion |_.Purpose|
|+assert( boolean, [msg] )+ |Ensures that the object/expression is true.|
|+assert_equal( obj1, obj2, [msg] )+ |Ensures that +obj1 == obj2+ is true.|
|+assert_not_equal( obj1, obj2, [msg] )+ |Ensures that +obj1 == obj2+ is false.|
@@ -413,7 +413,7 @@ h4. Rails Specific Assertions
Rails adds some custom assertions of its own to the +test/unit+ framework:
-|_.Assertion |_.Purpose|
+|_.Assertion |_.Purpose|
|+assert_valid(record)+ |Ensures that the passed record is valid by Active Record standards and returns any error messages if it is not.|
|+assert_difference(expressions, difference = 1, message = nil) {...}+ |Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.|
|+assert_no_difference(expressions, message = nil, &block)+ |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
@@ -550,7 +550,7 @@ NOTE: You may find references to +assert_tag+ in other documentation, but this i
There are two forms of +assert_select+:
-+assert_select(selector, [equality], [message])`+ ensures that the equality condition is met on the selected elements through the selector. The selector may be a CSS selector expression (String), an expression with substitution values, or an +HTML::Selector+ object.
++assert_select(selector, [equality], [message])+ ensures that the equality condition is met on the selected elements through the selector. The selector may be a CSS selector expression (String), an expression with substitution values, or an +HTML::Selector+ object.
+assert_select(element, selector, [equality], [message])+ ensures that the equality condition is met on all the selected elements through the selector starting from the _element_ (instance of +HTML::Node+) and its descendants.
@@ -588,7 +588,7 @@ h5. Additional View-based Assertions
There are more assertions that are primarily used in testing views:
-|_.Assertion |_.Purpose|
+|_.Assertion |_.Purpose|
|+assert_select_email+ |Allows you to make assertions on the body of an e-mail. |
|+assert_select_rjs+ |Allows you to make assertions on RJS response. +assert_select_rjs+ has variants which allow you to narrow down on the updated element or even a particular operation on an element.|
|+assert_select_encoded+ |Allows you to make assertions on encoded HTML. It does this by un-encoding the contents of each element and then calling the block with all the un-encoded elements.|
@@ -635,7 +635,7 @@ h4. Helpers Available for Integration tests
In addition to the standard testing helpers, there are some additional helpers available to integration tests:
-|_.Helper |_.Purpose|
+|_.Helper |_.Purpose|
|+https?+ |Returns +true+ if the session is mimicking a secure HTTPS request.|
|+https!+ |Allows you to mimic a secure HTTPS request.|
|+host!+ |Allows you to set the host name to use in the next request.|
@@ -732,7 +732,7 @@ h3. Rake Tasks for Running your Tests
You don't need to set up and run your tests by hand on a test-by-test basis. Rails comes with a number of rake tasks to help in testing. The table below lists all rake tasks that come along in the default Rakefile when you initiate a Rail project.
-|_.Tasks |_.Description|
+|_.Tasks |_.Description|
|+rake test+ |Runs all unit, functional and integration tests. You can also simply run +rake+ as the _test_ target is the default.|
|+rake test:units+ |Runs all the unit tests from +test/unit+|
|+rake test:functionals+ |Runs all the functional tests from +test/functional+|