require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "select_datetime" do it "should send the values for each individual date and time components" do with_html <<-HTML

:
HTML webrat_session.should_receive(:post).with("http://www.example.com/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) select_datetime "December 25, 2003 9:30", :from => "Time" click_button end it "should accept a time object" do with_html <<-HTML

:
HTML webrat_session.should_receive(:post).with("http://www.example.com/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) select_datetime Time.parse("December 25, 2003 9:30"), :from => "Time" click_button end it "should work when the label ends in a non word character" do with_html <<-HTML

:
HTML webrat_session.should_receive(:post).with("http://www.example.com/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) select_datetime "December 25, 2003 9:30", :from => "Time ?" click_button end it "should work when no label is specified" do with_html <<-HTML
:
HTML webrat_session.should_receive(:post).with("http://www.example.com/appointments", "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) select_datetime "December 25, 2003 9:30" click_button end it "should fail if the specified label is not found" do with_html <<-HTML
HTML lambda { select_datetime "December 25, 2003 9:30", :from => "Time" }.should raise_error(Webrat::NotFoundError) end end