aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/testing_rails_applications.txt
diff options
context:
space:
mode:
authorColin Law <colin@clanlaw.org.uk>2009-01-11 11:56:53 +0000
committerColin Law <colin@clanlaw.org.uk>2009-01-11 11:56:53 +0000
commit3e60ea6c231810e2b850492a86874b4800dfbf27 (patch)
tree16a430a9d76da40b8e27b0f61ddb3d2d21cddcbd /railties/doc/guides/source/testing_rails_applications.txt
parenta2a0b44a9adb2c34770f2eef7e8db435bcdce55c (diff)
downloadrails-3e60ea6c231810e2b850492a86874b4800dfbf27.tar.gz
rails-3e60ea6c231810e2b850492a86874b4800dfbf27.tar.bz2
rails-3e60ea6c231810e2b850492a86874b4800dfbf27.zip
Clarified use of assert_select with blocks in testing guide and rdoc text
Diffstat (limited to 'railties/doc/guides/source/testing_rails_applications.txt')
-rw-r--r--railties/doc/guides/source/testing_rails_applications.txt19
1 files changed, 17 insertions, 2 deletions
diff --git a/railties/doc/guides/source/testing_rails_applications.txt b/railties/doc/guides/source/testing_rails_applications.txt
index d29988485a..054260e276 100644
--- a/railties/doc/guides/source/testing_rails_applications.txt
+++ b/railties/doc/guides/source/testing_rails_applications.txt
@@ -592,7 +592,7 @@ For example, you could verify the contents on the title element in your response
assert_select 'title', "Welcome to Rails Testing Guide"
--------------------------------------------------
-You can also use nested +assert_select+ blocks. In this case the inner +assert_select+ will run the assertion on each element selected by the outer `assert_select` block:
+You can also use nested +assert_select+ blocks. In this case the inner +assert_select+ runs the assertion on the complete collection of elements selected by the outer `assert_select` block:
[source,ruby]
--------------------------------------------------
@@ -601,7 +601,22 @@ assert_select 'ul.navigation' do
end
--------------------------------------------------
-The +assert_select+ assertion is quite powerful. For more advanced usage, refer to its link:http://api.rubyonrails.com/classes/ActionController/Assertions/SelectorAssertions.html#M000749[documentation].
+Alternatively the collection of elements selected by the outer +assert_select+ may be iterated through so that +assert_select+ may be called separately for each element. Suppose for example that the response contains two ordered lists, each with four list elements then the following tests will both pass.
+
+[source,ruby]
+--------------------------------------------------
+assert_select "ol" do |elements|
+ elements.each do |element|
+ assert_select element, "li", 4
+ end
+end
+
+assert_select "ol" do
+ assert_select "li", 8
+end
+--------------------------------------------------
+
+The +assert_select+ assertion is quite powerful. For more advanced usage, refer to its link:http://api.rubyonrails.com/classes/ActionController/Assertions/SelectorAssertions.html[documentation].
==== Additional View-based Assertions ====