Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selects_time, selects_date, and selects_datetime added to API. Closes …
…#36.
- Loading branch information
Showing
11 changed files
with
564 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ email.txt | |
log | ||
.project | ||
.loadpath | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ def text | |
str.squeeze!(" ") | ||
str | ||
end | ||
|
||
def for_id | ||
@element['for'] | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | ||
|
||
describe "selects_date" do | ||
before do | ||
@session = Webrat::TestSession.new | ||
end | ||
|
||
it "should send the values for each individual date component" do | ||
@session.response_body = <<-EOS | ||
<form action="/appointments" method="post"> | ||
<label for="appointment_date">Date</label><br /> | ||
<select id="appointment_date_1i" name="appointment[date(1i)]"> | ||
<option value="2003">2003</option> | ||
</select> | ||
<select id="appointment_date_2i" name="appointment[date(2i)]"> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="appointment_date_3i" name="appointment[date(3i)]"> | ||
<option value="25">25</option> | ||
</select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
@session.should_receive(:post).with("/appointments", | ||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) | ||
@session.selects_date "December 25, 2003", :from => "Date" | ||
@session.click_button | ||
end | ||
|
||
it "should select the date components with the suffix convention provided" do | ||
@session.response_body = <<-EOS | ||
<form action="/appointments" method="post"> | ||
<label for="appointment_date">Date</label><br /> | ||
<select id="appointment_date_year" name="appointment[year]"> | ||
<option value="2003">2003</option> | ||
</select> | ||
<select id="appointment_date_month" name="appointment[month]"> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="appointment_date_day" name="appointment[day]"> | ||
<option value="25">25</option> | ||
</select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
@session.should_receive(:post).with("/appointments", | ||
"appointment" => {"year" => '2003', "month" => "12", "day" => "25"}) | ||
@session.selects_date "December 25, 2003 9:30", :from => "Date", :suffix_convention => :full_words | ||
@session.click_button | ||
end | ||
|
||
it "should select the date components with the suffixes provided" do | ||
@session.response_body = <<-EOS | ||
<form action="/appointments" method="post"> | ||
<label for="appointment_date">Date</label><br /> | ||
<select id="appointment_date_y" name="appointment[y]"> | ||
<option value="2003">2003</option> | ||
</select> | ||
<select id="appointment_date_mo" name="appointment[mo]"> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="appointment_date_d" name="appointment[d]"> | ||
<option value="25">25</option> | ||
</select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
@session.should_receive(:post).with("/appointments", | ||
"appointment" => {"y" => '2003', "mo" => "12", "d" => "25"}) | ||
@session.selects_date "December 25, 2003 9:30", :from => "Date", | ||
:suffixes => {:year => 'y', :month => 'mo', :day => 'd'} | ||
@session.click_button | ||
end | ||
|
||
|
||
it "should accept a date object" do | ||
@session.response_body = <<-EOS | ||
<form action="/appointments" method="post"> | ||
<label for="appointment_date">date</label><br /> | ||
<select id="appointment_date_1i" name="appointment[date(1i)]"> | ||
<option value="2003">2003</option> | ||
</select> | ||
<select id="appointment_date_2i" name="appointment[date(2i)]"> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="appointment_date_3i" name="appointment[date(3i)]"> | ||
<option value="25">25</option> | ||
</select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
@session.should_receive(:post).with("/appointments", | ||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) | ||
@session.selects_date Date.parse("December 25, 2003"), :from => "date" | ||
@session.click_button | ||
end | ||
|
||
it "should work when no label is specified" do | ||
@session.response_body = <<-EOS | ||
<form action="/appointments" method="post"> | ||
<select id="appointment_date_1i" name="appointment[date(1i)]"> | ||
<option value="2003">2003</option> | ||
</select> | ||
<select id="appointment_date_2i" name="appointment[date(2i)]"> | ||
<option value="12">December</option> | ||
</select> | ||
<select id="appointment_date_3i" name="appointment[date(3i)]"> | ||
<option value="25">25</option> | ||
</select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
@session.should_receive(:post).with("/appointments", | ||
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) | ||
@session.selects_date "December 25, 2003" | ||
@session.click_button | ||
end | ||
|
||
it "should fail if the specified label is not found" do | ||
@session.response_body = <<-EOS | ||
<form method="post" action="/appointments"> | ||
<select name="month"><option>January</option></select> | ||
<input type="submit" /> | ||
</form> | ||
EOS | ||
|
||
lambda { @session.selects_date "December 25, 2003", :from => "date" }.should raise_error | ||
end | ||
|
||
end |
Oops, something went wrong.