require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "date_selects" do before do @session = Webrat::TestSession.new @example_date_select = <<-EOS

EOS end it "should fail if option not found" do @session.response_body = @example_date_select lambda { @session.selects_date "2008-07-13"}.should raise_error end it "should fail if option not found in list specified by element name" do @session.response_body = @example_date_select lambda { @session.selects_date "2008-07-13", :from => "created_at" }.should raise_error end it "should fail if specified list not found" do @session.response_body = <<-EOS
EOS lambda { @session.selects_date "2003-12-01", :from => "created_at" }.should raise_error end it "should send value from option" do @session.response_body = <<-EOS


EOS @session.should_receive(:post).with("/login", "created_at(1i)" => "2003", 'created_at(2i)' => '12', 'created_at(3i)' => '1', "updated_at(1i)" => "", 'updated_at(2i)' => '', 'updated_at(3i)' => '') @session.selects_date '2003-12-01', :from => "created_at" @session.clicks_button end it "should work without specifying the field name or label" do @session.response_body = @example_date_select @session.should_receive(:post).with("/login", "created_at(1i)" => "2003", 'created_at(2i)' => '12', 'created_at(3i)' => '1') @session.selects_date '2003-12-01' @session.clicks_button end it "should correctly set day and month when there are the same options available" do @session.response_body = <<-EOS

EOS @session.should_receive(:post).with("/login", "created_at(1i)" => "2003", 'created_at(2i)' => '12', 'created_at(3i)' => '1') @session.selects_date '2003-12-01' @session.clicks_button end end