Updating usages of "selects" methods to "select"
This commit is contained in:
parent
f03905e6b6
commit
db0488c0e2
|
@ -90,10 +90,10 @@ module Webrat
|
||||||
# a label. Stores the option's value to be sent when the form is submitted.
|
# a label. Stores the option's value to be sent when the form is submitted.
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# selects "January"
|
# select "January"
|
||||||
# selects "February", :from => "event_month"
|
# select "February", :from => "event_month"
|
||||||
# selects "February", :from => "Event Month"
|
# select "February", :from => "Event Month"
|
||||||
def selects(option_text, options = {})
|
def select(option_text, options = {})
|
||||||
if option = find_select_option(option_text, options[:from])
|
if option = find_select_option(option_text, options[:from])
|
||||||
option.choose
|
option.choose
|
||||||
else
|
else
|
||||||
|
@ -102,7 +102,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :select, :selects
|
alias_method :selects, :select
|
||||||
|
|
||||||
DATE_TIME_SUFFIXES = {
|
DATE_TIME_SUFFIXES = {
|
||||||
:year => '1i',
|
:year => '1i',
|
||||||
|
@ -123,11 +123,11 @@ module Webrat
|
||||||
# by assigning <tt>options[:id_prefix]</tt>.
|
# by assigning <tt>options[:id_prefix]</tt>.
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# selects_date "January 23, 2004"
|
# select_date "January 23, 2004"
|
||||||
# selects_date "April 26, 1982", :from => "Birthday"
|
# select_date "April 26, 1982", :from => "Birthday"
|
||||||
# selects_date Date.parse("December 25, 2000"), :from => "Event"
|
# select_date Date.parse("December 25, 2000"), :from => "Event"
|
||||||
# selects_date "April 26, 1982", :id_prefix => 'birthday'
|
# select_date "April 26, 1982", :id_prefix => 'birthday'
|
||||||
def selects_date(date_to_select, options ={})
|
def select_date(date_to_select, options ={})
|
||||||
date = date_to_select.is_a?(Date) || date_to_select.is_a?(Time) ?
|
date = date_to_select.is_a?(Date) || date_to_select.is_a?(Time) ?
|
||||||
date_to_select : Date.parse(date_to_select)
|
date_to_select : Date.parse(date_to_select)
|
||||||
|
|
||||||
|
@ -137,12 +137,12 @@ module Webrat
|
||||||
$1
|
$1
|
||||||
end
|
end
|
||||||
|
|
||||||
selects date.year, :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:year]}"
|
select date.year, :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:year]}"
|
||||||
selects date.strftime('%B'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:month]}"
|
select date.strftime('%B'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:month]}"
|
||||||
selects date.day, :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:day]}"
|
select date.day, :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:day]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :select_date, :selects_date
|
alias_method :selects_date, :select_date
|
||||||
|
|
||||||
# Verifies that time elements (hour, minute) exist on the current page
|
# Verifies that time elements (hour, minute) exist on the current page
|
||||||
# with the specified values. You can optionally restrict the search to a specific
|
# with the specified values. You can optionally restrict the search to a specific
|
||||||
|
@ -158,11 +158,11 @@ module Webrat
|
||||||
# 24 hour select boxes, and not 12 hours with AM/PM.
|
# 24 hour select boxes, and not 12 hours with AM/PM.
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# selects_time "9:30"
|
# select_time "9:30"
|
||||||
# selects_date "3:30PM", :from => "Party Time"
|
# select_date "3:30PM", :from => "Party Time"
|
||||||
# selects_date Time.parse("10:00PM"), :from => "Event"
|
# select_date Time.parse("10:00PM"), :from => "Event"
|
||||||
# selects_date "10:30AM", :id_prefix => 'meeting'
|
# select_date "10:30AM", :id_prefix => 'meeting'
|
||||||
def selects_time(time_to_select, options ={})
|
def select_time(time_to_select, options ={})
|
||||||
time = time_to_select.is_a?(Time) ? time_to_select : Time.parse(time_to_select)
|
time = time_to_select.is_a?(Time) ? time_to_select : Time.parse(time_to_select)
|
||||||
|
|
||||||
id_prefix = locate_id_prefix(options) do
|
id_prefix = locate_id_prefix(options) do
|
||||||
|
@ -171,31 +171,31 @@ module Webrat
|
||||||
$1
|
$1
|
||||||
end
|
end
|
||||||
|
|
||||||
selects time.hour.to_s.rjust(2,'0'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:hour]}"
|
select time.hour.to_s.rjust(2,'0'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:hour]}"
|
||||||
selects time.min.to_s.rjust(2,'0'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:minute]}"
|
select time.min.to_s.rjust(2,'0'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:minute]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
alias_method :select_time, :selects_time
|
alias_method :selects_time, :select_time
|
||||||
|
|
||||||
# Verifies and selects all the date and time elements on the current page.
|
# Verifies and selects all the date and time elements on the current page.
|
||||||
# See #selects_time and #selects_date for more details and available options.
|
# See #select_time and #select_date for more details and available options.
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# selects_datetime "January 23, 2004 10:30AM"
|
# select_datetime "January 23, 2004 10:30AM"
|
||||||
# selects_datetime "April 26, 1982 7:00PM", :from => "Birthday"
|
# select_datetime "April 26, 1982 7:00PM", :from => "Birthday"
|
||||||
# selects_datetime Time.parse("December 25, 2000 15:30"), :from => "Event"
|
# select_datetime Time.parse("December 25, 2000 15:30"), :from => "Event"
|
||||||
# selects_datetime "April 26, 1982 5:50PM", :id_prefix => 'birthday'
|
# select_datetime "April 26, 1982 5:50PM", :id_prefix => 'birthday'
|
||||||
def selects_datetime(time_to_select, options ={})
|
def select_datetime(time_to_select, options ={})
|
||||||
time = time_to_select.is_a?(Time) ? time_to_select : Time.parse(time_to_select)
|
time = time_to_select.is_a?(Time) ? time_to_select : Time.parse(time_to_select)
|
||||||
|
|
||||||
options[:id_prefix] ||= (options[:from] ? find_field_with_id(options[:from]) : nil)
|
options[:id_prefix] ||= (options[:from] ? find_field_with_id(options[:from]) : nil)
|
||||||
|
|
||||||
selects_date time, options
|
select_date time, options
|
||||||
selects_time time, options
|
select_time time, options
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :select_datetime, :selects_datetime
|
alias_method :selects_datetime, :select_datetime
|
||||||
|
|
||||||
# Verifies that an input file field exists on the current page and sets
|
# Verifies that an input file field exists on the current page and sets
|
||||||
# its value to the given +file+, so that the file will be uploaded
|
# its value to the given +file+, so that the file will be uploaded
|
||||||
|
|
|
@ -79,7 +79,7 @@ module Webrat
|
||||||
wait_for_effects
|
wait_for_effects
|
||||||
end
|
end
|
||||||
|
|
||||||
def selects(option_text, options = {})
|
def select(option_text, options = {})
|
||||||
id_or_name_or_label = options[:from]
|
id_or_name_or_label = options[:from]
|
||||||
|
|
||||||
if id_or_name_or_label
|
if id_or_name_or_label
|
||||||
|
@ -90,6 +90,8 @@ module Webrat
|
||||||
@selenium.select(select_locator, option_text)
|
@selenium.select(select_locator, option_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_method :selects, :select
|
||||||
|
|
||||||
def choose(label_text)
|
def choose(label_text)
|
||||||
@selenium.click("webrat=#{label_text}")
|
@selenium.click("webrat=#{label_text}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
||||||
|
|
||||||
describe "selects_date" do
|
describe "select_date" do
|
||||||
it "should send the values for each individual date component" do
|
it "should send the values for each individual date component" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<form action="/appointments" method="post">
|
<form action="/appointments" method="post">
|
||||||
|
@ -19,7 +19,7 @@ describe "selects_date" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
||||||
selects_date "December 25, 2003", :from => "Date"
|
select_date "December 25, 2003", :from => "Date"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ describe "selects_date" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
||||||
selects_date Date.parse("December 25, 2003"), :from => "date"
|
select_date Date.parse("December 25, 2003"), :from => "date"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ describe "selects_date" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
|
||||||
selects_date "December 25, 2003"
|
select_date "December 25, 2003"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ describe "selects_date" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects_date "December 25, 2003", :from => "date" }.should raise_error
|
lambda { select_date "December 25, 2003", :from => "date" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
||||||
|
|
||||||
describe "selects_datetime" do
|
describe "select_datetime" do
|
||||||
it "should send the values for each individual date and time components" do
|
it "should send the values for each individual date and time components" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<form action="/appointments" method="post">
|
<form action="/appointments" method="post">
|
||||||
|
@ -25,7 +25,7 @@ describe "selects_datetime" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
|
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
|
||||||
selects_datetime "December 25, 2003 9:30", :from => "Time"
|
select_datetime "December 25, 2003 9:30", :from => "Time"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ describe "selects_datetime" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
|
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
|
||||||
selects_datetime "December 25, 2003 9:30"
|
select_datetime "December 25, 2003 9:30"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ describe "selects_datetime" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects_datetime "December 25, 2003 9:30", :from => "Time" }.should raise_error
|
lambda { select_datetime "December 25, 2003 9:30", :from => "Time" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
||||||
|
|
||||||
describe "selects" do
|
describe "select" do
|
||||||
it "should fail with a helpful message when option not found" do
|
it "should fail with a helpful message when option not found" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<form method="get" action="/login">
|
<form method="get" action="/login">
|
||||||
|
@ -8,8 +8,8 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects "February", :from => "month" }.should raise_error(
|
lambda { select "February", :from => "month" }.should raise_error(Webrat::NotFoundError,
|
||||||
Exception, "The 'February' option was not found in the 'month' select box")
|
"The 'February' option was not found in the 'month' select box")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if option not found in list specified by element name" do
|
it "should fail if option not found in list specified by element name" do
|
||||||
|
@ -20,7 +20,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects "February", :from => "year" }.should raise_error
|
lambda { select "February", :from => "year" }.should raise_error(Webrat::NotFoundError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if specified list not found" do
|
it "should fail if specified list not found" do
|
||||||
|
@ -30,7 +30,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects "February", :from => "year" }.should raise_error
|
lambda { select "February", :from => "year" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda { selects "January", :from => "month" }.should raise_error
|
lambda { select "January", :from => "month" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send value from option" do
|
it "should send value from option" do
|
||||||
|
@ -53,7 +53,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
||||||
selects "January", :from => "month"
|
select "January", :from => "month"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "encoded" => "A & B")
|
webrat_session.should_receive(:post).with("/login", "encoded" => "A & B")
|
||||||
selects "Encoded", :from => "encoded"
|
select "Encoded", :from => "encoded"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
||||||
selects "January"
|
select "January"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
selects "January", :from => "end_month"
|
select "January", :from => "end_month"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
selects "January", :from => "End Month"
|
select "January", :from => "End Month"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
||||||
selects "January", :from => "month"
|
select "January", :from => "month"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
||||||
selects(/jan/i)
|
select /jan/i
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,8 +153,8 @@ describe "selects" do
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
selects(/feb/i)
|
select /feb/i
|
||||||
}.should raise_error
|
}.should raise_error(Webrat::NotFoundError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should find option by regexp in list specified by label" do
|
it "should find option by regexp in list specified by label" do
|
||||||
|
@ -168,7 +168,7 @@ describe "selects" do
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
selects(/jan/i, :from => "End Month")
|
select /jan/i, :from => "End Month"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe "select_time" do
|
||||||
HTML
|
HTML
|
||||||
webrat_session.should_receive(:post).with("/appointments",
|
webrat_session.should_receive(:post).with("/appointments",
|
||||||
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
|
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
|
||||||
selects_time "9:30AM", :from => "Time"
|
select_time "9:30AM", :from => "Time"
|
||||||
click_button
|
click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue