Permalink
Browse files

one render per test

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5251 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a49e7d5 commit 5d1edc55a8462f3fa88c9801ceb01c60db50884b @jeremy jeremy committed Oct 9, 2006
Showing with 36 additions and 16 deletions.
  1. +36 −16 actionpack/test/controller/assert_select_test.rb
@@ -203,7 +203,8 @@ def test_assert_select_text_match
end
- def test_assert_select_from_rjs
+ # With single result.
+ def test_assert_select_from_rjs_with_single_result
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
end
@@ -216,7 +217,10 @@ def test_assert_select_from_rjs
assert_select "#1"
assert_select "#2"
end
- # With multiple results.
+ end
+
+ # With multiple results.
+ def test_assert_select_from_rjs_with_multiple_results
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>"
page.replace_html "test2", "<div id=\"2\">foo</div>"
@@ -260,19 +264,23 @@ def test_nested_css_select
end
- def test_css_select_from_rjs
- # With one result.
+ # With one result.
+ def test_css_select_from_rjs_with_single_result
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
end
assert_equal 2, css_select("div").size
assert_equal 1, css_select("#1").size
assert_equal 1, css_select("#2").size
- # With multiple results.
+ end
+
+ # With multiple results.
+ def test_css_select_from_rjs_with_multiple_results
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>"
page.replace_html "test2", "<div id=\"2\">foo</div>"
end
+
assert_equal 2, css_select("div").size
assert_equal 1, css_select("#1").size
assert_equal 1, css_select("#2").size
@@ -284,13 +292,14 @@ def test_css_select_from_rjs
#
- def test_assert_select_rjs
- # Test that we can pick up all statements in the result.
+ # Test that we can pick up all statements in the result.
+ def test_assert_select_rjs_picks_up_all_statements
render_rjs do |page|
page.replace "test", "<div id=\"1\">foo</div>"
page.replace_html "test2", "<div id=\"2\">foo</div>"
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
end
+
found = false
assert_select_rjs do
assert_select "#1"
@@ -299,9 +308,11 @@ def test_assert_select_rjs
found = true
end
assert found
- # Test that we fail if there is nothing to pick.
- render_rjs do |page|
- end
+ end
+
+ # Test that we fail if there is nothing to pick.
+ def test_assert_select_rjs_fails_if_nothing_to_pick
+ render_rjs { }
assert_raises(AssertionFailedError) { assert_select_rjs }
end
@@ -397,13 +408,13 @@ def test_assert_select_rjs_for_chained_replace
assert_raises(AssertionFailedError) { assert_select_rjs :replace_html, "test1" }
end
- def test_assert_select_rjs_for_insert
+ # Non-positioned insert.
+ def test_assert_select_rjs_for_nonpositioned_insert
render_rjs do |page|
page.replace "test1", "<div id=\"1\">foo</div>"
page.replace_html "test2", "<div id=\"2\">foo</div>"
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
end
- # Non-positioned.
assert_select_rjs :insert_html do
assert_select "div", 1
assert_select "#3"
@@ -413,7 +424,10 @@ def test_assert_select_rjs_for_insert
assert_select "#3"
end
assert_raises(AssertionFailedError) { assert_select_rjs :insert_html, "test1" }
- # Positioned.
+ end
+
+ # Positioned insert.
+ def test_assert_select_rjs_for_positioned_insert
render_rjs do |page|
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
@@ -442,25 +456,31 @@ def test_assert_select_rjs_for_insert
end
- def test_nested_assert_select_rjs
- # Simple selection from a single result.
+ # Simple selection from a single result.
+ def test_nested_assert_select_rjs_with_single_result
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
end
+
assert_select_rjs "test" do |elements|
assert_equal 2, elements.size
assert_select "#1"
assert_select "#2"
end
- # Deal with two results.
+ end
+
+ # Deal with two results.
+ def test_nested_assert_select_rjs_with_two_results
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>"
page.replace_html "test2", "<div id=\"2\">foo</div>"
end
+
assert_select_rjs "test" do |elements|
assert_equal 1, elements.size
assert_select "#1"
end
+
assert_select_rjs "test2" do |elements|
assert_equal 1, elements.size
assert_select "#2"

0 comments on commit 5d1edc5

Please sign in to comment.