diff --git a/lib/webrat/core/locators/select_option_locator.rb b/lib/webrat/core/locators/select_option_locator.rb index 49df2b0..123755e 100644 --- a/lib/webrat/core/locators/select_option_locator.rb +++ b/lib/webrat/core/locators/select_option_locator.rb @@ -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 diff --git a/spec/public/select_spec.rb b/spec/public/select_spec.rb index 22f722f..d0d05d0 100644 --- a/spec/public/select_spec.rb +++ b/spec/public/select_spec.rb @@ -168,6 +168,36 @@ describe "select" do click_button end + it "should find options by regexp with HTML entities" do + with_html <<-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 + + 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 @@ -201,31 +231,47 @@ describe "select" do end it "should properly handle submitting HTML entities in select values" do - with_html <<-HTML - -
- - -
- - HTML - webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly") - click_button + with_html <<-HTML + +
+ + +
+ + HTML + + webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly") + click_button end it "should properly handle locating with HTML entities in select values" do - with_html <<-HTML - -
- - -
- - HTML + with_html <<-HTML + +
+ + +
+ + HTML - lambda { - select "Peanut butter & jelly" - }.should_not raise_error(Webrat::NotFoundError) + webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly") + select "Peanut butter & jelly" + click_button + end + + it "should not locate based on HTML entities" do + with_html <<-HTML + +
+ + +
+ + HTML + + lambda { + select "Peanut butter & jelly" + }.should raise_error(Webrat::NotFoundError) end it "should submit duplicates selected options as a single value" do