From 806cf6d76ab557ceebf5ac5d22f3e39076e1ab61 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 17 Apr 2005 16:43:48 +0000 Subject: Added assert_tag and assert_no_tag as a much improved alternative to the deprecated assert_template_xpath_match #1126 [Jamis Buck] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1195 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index f92e9dae48..7b35447da5 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -9,6 +9,26 @@ class TestTest < Test::Unit::TestCase def test_uri render_text @request.request_uri end + + def test_html_output + render_text < + +
+ +
+
+
+ Name: +
+
+ + +HTML + end end def setup @@ -47,4 +67,21 @@ class TestTest < Test::Unit::TestCase process :test_uri, :id => 7 assert_equal @response.body, "/explicit/uri" end + + def test_assert_tag + process :test_html_output + + # there is a 'div', id='bar', with an immediate child whose 'action' + # attribute matches the regexp /somewhere/. + assert_tag :tag => "div", :attributes => { :id => "bar" }, + :child => { :attributes => { :action => /somewhere/ } } + + # there is no 'div', id='foo', with a 'ul' child with more than + # 2 "li" children. + assert_no_tag :tag => "div", :attributes => { :id => "foo" }, + :child => { + :tag => "ul", + :children => { :greater_than => 2, + :only => { :tag => "li" } } } + end end -- cgit v1.2.3