spec/ratis/next_bus_spec.rb in ratis-3.1.4 vs spec/ratis/next_bus_spec.rb in ratis-3.1.5

- old
+ new

@@ -18,20 +18,40 @@ pending end end describe '#where' do + describe 'time formatting' do + it 'should make requests with 24 hour time format' do + @stop_id = 10050 + @time = Chronic.parse('tomorrow at 3pm') + @conditions = {:stop_id => @stop_id, + :app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with + :type => 'N', + :datetime => @time } + + Ratis::Request.should_receive(:get) do |action, options| + action.should eq('Nextbus') + options["Time"].should eq(@time.strftime("%H%M")) + + end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running + + Ratis::NextBus.where(@conditions.dup) + end + end + describe 'single service return' do before do @stop_id = 10050 @conditions = {:stop_id => @stop_id, :app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with :type => 'N', :datetime => @time } + end - it 'returns the next 4 bus times' do + it 'returns the next bus times' do # raises exception when no runs available: # Ratis::Errors::SoapError: # SOAP - no runs available response = Ratis::NextBus.where(@conditions.dup) expect(response.services).to have(1).items @@ -47,11 +67,11 @@ Ratis::Request.should_receive(:get) do |action, options| action.should eq('Nextbus') options["Stopid"].should eq(@stop_id) options["Appid"].should eq('ratis-specs') options["Date"].should eq(@time.strftime("%m/%d/%Y")) - options["Time"].should eq(@time.strftime("%I%M")) + options["Time"].should eq(@time.strftime("%H%M")) options["Type"].should eq('N') end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running Ratis::NextBus.where(@conditions.dup) @@ -97,11 +117,11 @@ Ratis::Request.should_receive(:get) do |action, options| action.should eq('Nextbus') options["Stopid"].should eq(@stop_id) options["Appid"].should eq('ratis-specs') options["Date"].should eq(@time.strftime("%m/%d/%Y")) - options["Time"].should eq(@time.strftime("%I%M")) + options["Time"].should eq(@time.strftime("%H%M")) options["Type"].should eq('N') end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running expect(Ratis::NextBus.where(@conditions.dup).services).to be_empty @@ -135,11 +155,11 @@ Ratis::Request.should_receive(:get) do |action, options| action.should eq('Nextbus') options["Stopid"].should eq(@stop_id) options["Appid"].should eq('ratis-specs') options["Date"].should eq(@time.strftime("%m/%d/%Y")) - options["Time"].should eq(@time.strftime("%I%M")) + options["Time"].should eq(@time.strftime("%H%M")) options["Type"].should eq('N') end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running Ratis::NextBus.where(@conditions.dup) @@ -196,10 +216,10 @@ end it "should return an empty array if the api request isn't successful" do Ratis::Request.should_receive('get') do |action, options| action.should eq('Nextbus') - options["Time"].should eq(@time.strftime("%I%M") ) + options["Time"].should eq(@time.strftime("%H%M") ) options["Type"].should eq("N") options["Stopid"].should eq(@stop_id) options["Date"].should eq(@time.strftime("%m/%d/%Y") ) options["Appid"].should eq("ratis-specs")