Permalink
Browse files

Fix assert_tag so that :content => "foo" does not match substrings, b…

…ut only exact strings. Use :content => /foo/ to match substrings. closes #2799

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5086 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jamis committed Sep 10, 2006
1 parent 5bf41ed commit 3f0952d9df1db6e01ca608f30ba743f3e7d54dcc
View
@@ -1,5 +1,7 @@
*SVN*
+* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel]
+
* Add descriptive messages to the exceptions thrown by cgi_methods. #6091, #6103 [Nicholas Seckar, Bob Silva]
* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com]
@@ -239,7 +239,7 @@ def find(conditions)
def match(conditions)
case conditions
when String
- @content.index(conditions)
+ @content == conditions
when Regexp
@content =~ conditions
when Hash
@@ -253,9 +253,9 @@ def test_assert_tag_content
process :test_html_output
# the output contains the string "Name"
- assert_tag :content => "Name"
+ assert_tag :content => /Name/
# the output does not contain the string "test"
- assert_no_tag :content => "test"
+ assert_no_tag :content => /test/
end
def test_assert_tag_multiple
@@ -301,6 +301,13 @@ def test_assert_tag_attribute_matching
:attributes => { :name => /^my$/, :type => 'text' }
end
+ def test_assert_tag_content_matching
+ @response.body = "<p>hello world</p>"
+ assert_tag :tag => "p", :content => "hello world"
+ assert_tag :tag => "p", :content => /hello/
+ assert_no_tag :tag => "p", :content => "hello"
+ end
+
def test_assert_generates
assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5'
end

0 comments on commit 3f0952d

Please sign in to comment.