Skip to content

Commit

Permalink
Remove the leading \n added by textarea on assert_select
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Mar 30, 2012
1 parent 5284e65 commit 5c7bb86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 3.2.3 (unreleased) ##

* Remove the leading \n added by textarea on assert_select. *Santiago Pastorino*

* Fix #5632, render :inline set the proper rendered format. *Santiago Pastorino*

* Fix textarea rendering when using plugins like HAML. Such plugins encode the first newline character in the content. This issue was introduced in https://github.com/rails/rails/pull/5191 *James Coleman*
Expand Down
Expand Up @@ -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 ||= build_message(message, "<?> expected but was\n<?>.", match_with, text)
true
Expand Down
7 changes: 7 additions & 0 deletions actionpack/test/controller/assert_select_test.rb
Expand Up @@ -135,6 +135,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 }
Expand Down

0 comments on commit 5c7bb86

Please sign in to comment.