Skip to content
This repository
Browse code

Remove the leading \n added by textarea on assert_select

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