Skip to content
Browse files

Remove the leading \n added by textarea on assert_select

  • Loading branch information...
1 parent 1ce7545 commit 1141f71601ff61fb299c86d814c07209f1430024 @spastorino spastorino committed Mar 30, 2012
View
2 actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Remove the leading \n added by textarea on assert_select. *Santiago Pastorino*
+
* Changed default value for `config.action_view.embed_authenticity_token_in_remote_forms`
to `false`. This change breaks remote forms that need to work also without javascript,
so if you need such behavior, you can either set it to `true` or explicitly pass
View
1 actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -269,6 +269,7 @@ def assert_select(*args, &block)
end
end
text.strip! unless NO_STRIP.include?(match.name)
+ text.sub!(/\A\n/, '') if match.name == "textarea"
unless match_with.is_a?(Regexp) ? (text =~ match_with) : (text == match_with.to_s)
content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, text)
true
View
7 actionpack/test/controller/assert_select_test.rb
@@ -131,6 +131,13 @@ def test_equality_of_html
assert_raise(Assertion) { assert_select "pre", :html=>text }
end
+ def test_strip_textarea
+ render_html %Q{<textarea>\n\nfoo\n</textarea>}
+ assert_select "textarea", "\nfoo\n"
+ render_html %Q{<textarea>\nfoo</textarea>}
+ assert_select "textarea", "foo"
+ end
+
def test_counts
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
assert_nothing_raised { assert_select "div", 2 }

0 comments on commit 1141f71

Please sign in to comment.
Something went wrong with that request. Please try again.