require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "selects_datetime" do before do @session = Webrat::TestSession.new end it "should send the values for each individual date and time components" do @session.response_body = <<-EOS

:
EOS @session.should_receive(:post).with("/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) @session.selects_datetime "December 25, 2003 9:30", :from => "Time" @session.click_button end it "should accept a time object" do @session.response_body = <<-EOS

:
EOS @session.should_receive(:post).with("/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) @session.select_datetime Time.parse("December 25, 2003 9:30"), :from => "Time" @session.click_button end it "should work when no label is specified" do @session.response_body = <<-EOS
:
EOS @session.should_receive(:post).with("/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) @session.selects_datetime "December 25, 2003 9:30" @session.click_button end it "should fail if the specified label is not found" do @session.response_body = <<-EOS
EOS lambda { @session.selects_datetime "December 25, 2003 9:30", :from => "Time" }.should raise_error end end