More clarification of select option locating behavior.
TODO: Ensure the other locators are all matching on text, not HTML
This commit is contained in:
parent
00c49a0521
commit
2490c247d2
@ -19,7 +19,7 @@ module Webrat
|
||||
|
||||
field.options.detect do |o|
|
||||
if @option_text.is_a?(Regexp)
|
||||
o.element.inner_html =~ @option_text
|
||||
o.element.inner_text =~ @option_text
|
||||
else
|
||||
o.inner_text == @option_text.to_s
|
||||
end
|
||||
@ -27,7 +27,7 @@ module Webrat
|
||||
else
|
||||
option_element = option_elements.detect do |o|
|
||||
if @option_text.is_a?(Regexp)
|
||||
o.inner_html =~ @option_text
|
||||
o.inner_text =~ @option_text
|
||||
else
|
||||
o.inner_text == @option_text.to_s
|
||||
end
|
||||
|
@ -168,6 +168,36 @@ describe "select" do
|
||||
click_button
|
||||
end
|
||||
|
||||
it "should find options by regexp with HTML entities" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<form method="post" action="/login">
|
||||
<select name="month"><option>Peanut butter & jelly</option></select>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
||||
select /Peanut butter & jelly/
|
||||
click_button
|
||||
end
|
||||
|
||||
it "should not find options by regexp with HTML entities in the regexp" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<form method="post" action="/login">
|
||||
<select name="month"><option>Peanut butter & jelly</option></select>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
lambda {
|
||||
select /Peanut butter & jelly/
|
||||
}.should raise_error(Webrat::NotFoundError)
|
||||
end
|
||||
|
||||
it "should fail if no option matching the regexp exists" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
@ -209,6 +239,7 @@ describe "select" do
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
||||
click_button
|
||||
end
|
||||
@ -223,9 +254,24 @@ describe "select" do
|
||||
</html>
|
||||
HTML
|
||||
|
||||
lambda {
|
||||
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
||||
select "Peanut butter & jelly"
|
||||
}.should_not raise_error(Webrat::NotFoundError)
|
||||
click_button
|
||||
end
|
||||
|
||||
it "should not locate based on HTML entities" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<form method="post" action="/login">
|
||||
<select name="month"><option>Peanut butter & jelly</option></select>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
lambda {
|
||||
select "Peanut butter & jelly"
|
||||
}.should raise_error(Webrat::NotFoundError)
|
||||
end
|
||||
|
||||
it "should submit duplicates selected options as a single value" do
|
||||
|
Loading…
Reference in New Issue
Block a user