提交 3f0952d9 编写于 作者: J Jamis Buck

Fix assert_tag so that :content => "foo" does not match substrings, but only...

Fix assert_tag so that :content => "foo" does not match substrings, but 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
上级 5bf41ed8
*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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册