Make Webrat::Label#text strip out newlines

This commit is contained in:
Miha Filej 2008-11-13 15:00:24 +01:00
parent 82c6be380e
commit 0f7a277c57
2 changed files with 22 additions and 1 deletions

View File

@ -11,7 +11,11 @@ module Webrat
end
def text
@element.inner_text
str = @element.inner_text
str.gsub!("\n","")
str.strip!
str.squeeze!(" ")
str
end
end

View File

@ -108,4 +108,21 @@ describe "field_labeled" do
with_an_id_of "element_42", :for => "The Label"
should_raise_error_matching /Could not find .* "Other Label"/, :for => "Other Label"
end
describe "finding a field with it's label containing newlines" do
using_this_html <<-HTML
<form>
<label for="element_42">
A label with
<a>a link on it's own line</a>
</label>
<input type="text" id="element_42">
</form>
HTML
should_return_a Webrat::TextField, :for => "A label with a link on it's own line"
with_an_id_of "element_42", :for => "A label with a link on it's own line"
should_raise_error_matching /Could not find .* "Other Label"/, :for => "Other Label"
end
end