From 461a77d1d9ae21de9b9956b082cf9bb48f62e872 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 22 Oct 2008 00:07:30 -0400 Subject: [PATCH] Revert "Support selecting options by their values (Alex Lang)" This reverts commit 1b51de8f0fda13778fe8e0ba5e86adf0982cbed6. Conflicts: History.txt --- History.txt | 3 +-- lib/webrat/core/field.rb | 14 +++----------- lib/webrat/core/select_option.rb | 4 ---- spec/api/selects_spec.rb | 12 ------------ 4 files changed, 4 insertions(+), 29 deletions(-) diff --git a/History.txt b/History.txt index db7eae6..4577bbb 100644 --- a/History.txt +++ b/History.txt @@ -12,8 +12,7 @@ * Minor enhancements * Add Webrat.root method for cross-framework support (Krzysztof Zylawy) - * Support selecting options by their values (Alex Lang) - * Support for clicking areas of an image map (Alex Lang) + * Add support for clicking areas of an image map (Alex Lang) * Add should_see and should_not_see for verifying HTML response bodys * Support relative links, including href="?foo=bar" (Kyle Hargraves) * Separated Rails-specific code from the Webrat core to make it easier to use Webrat with other environments diff --git a/lib/webrat/core/field.rb b/lib/webrat/core/field.rb index 42710cc..e8f7a4b 100644 --- a/lib/webrat/core/field.rb +++ b/lib/webrat/core/field.rb @@ -31,11 +31,11 @@ module Webrat end def matches_id?(id) - matches?(self.id, id) + @element["id"] == id.to_s end def matches_name?(name) - matches?(self.name, name) + @element["name"] == name.to_s end def matches_label?(label_text) @@ -70,14 +70,6 @@ module Webrat protected - def matches?(string, string_or_regex) - if string_or_regex.is_a?(Regexp) - string_or_regex.match string - else - string == string_or_regex - end - end - def id @element["id"] end @@ -308,7 +300,7 @@ module Webrat class SelectField < Field def find_option(text) - options.detect { |o| o.matches_text?(text) || o.matches_value?(text)} + options.detect { |o| o.matches_text?(text) } end protected diff --git a/lib/webrat/core/select_option.rb b/lib/webrat/core/select_option.rb index 8df63dd..c46224f 100644 --- a/lib/webrat/core/select_option.rb +++ b/lib/webrat/core/select_option.rb @@ -14,10 +14,6 @@ module Webrat end end - def matches_value?(value) - @element.attributes['value'] == value.to_s - end - def choose @select.raise_error_if_disabled @select.set(value) diff --git a/spec/api/selects_spec.rb b/spec/api/selects_spec.rb index 75e44d9..d33afce 100644 --- a/spec/api/selects_spec.rb +++ b/spec/api/selects_spec.rb @@ -108,18 +108,6 @@ describe "selects" do @session.clicks_button end - it "should send value from option in list specified by value" do - @session.response_body = <<-EOS -
- - -
- EOS - @session.should_receive(:post).with("/login", "start_month" => "s1") - @session.selects "s1", :from => "start_month" - @session.clicks_button - end - it "should send value from option in list specified by label" do @session.response_body = <<-EOS