Make Webrat::Label#text strip out newlines
This commit is contained in:
parent
82c6be380e
commit
0f7a277c57
|
@ -11,7 +11,11 @@ module Webrat
|
||||||
end
|
end
|
||||||
|
|
||||||
def text
|
def text
|
||||||
@element.inner_text
|
str = @element.inner_text
|
||||||
|
str.gsub!("\n","")
|
||||||
|
str.strip!
|
||||||
|
str.squeeze!(" ")
|
||||||
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,4 +108,21 @@ describe "field_labeled" do
|
||||||
with_an_id_of "element_42", :for => "The Label"
|
with_an_id_of "element_42", :for => "The Label"
|
||||||
should_raise_error_matching /Could not find .* "Other Label"/, :for => "Other Label"
|
should_raise_error_matching /Could not find .* "Other Label"/, :for => "Other Label"
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue