diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-17 16:43:48 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-17 16:43:48 +0000 |
commit | 806cf6d76ab557ceebf5ac5d22f3e39076e1ab61 (patch) | |
tree | 5ca7149e3f8ee758cb3b0fd2df096baf61824153 /actionpack/test | |
parent | 95e6c03de7cd52a426560a6c46bd08b1791d7022 (diff) | |
download | rails-806cf6d76ab557ceebf5ac5d22f3e39076e1ab61.tar.gz rails-806cf6d76ab557ceebf5ac5d22f3e39076e1ab61.tar.bz2 rails-806cf6d76ab557ceebf5ac5d22f3e39076e1ab61.zip |
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
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/test_test.rb | 37 |
1 files changed, 37 insertions, 0 deletions
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 <<HTML +<html> + <body> + <div id="foo"> + <ul> + <li class="item">hello</li> + <li class="item">goodbye</li> + </ul> + </div> + <div id="bar"> + <form action="/somewhere"> + Name: <input type="text" name="person[name]" id="person_name" /> + </form> + </div> + </body> +</html> +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 |