Sha256: 7b3a604e2cc08b97848118bb003a5d85b6f8ca2a361adbd45d6131dbe5e8e4ff

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe TripLeg do
  
  before do
  end

  it "ebt_time method produces correct Time with minutes" do
    dept_date_act_gmt = Date.new(2000,1,1)
    tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
                     :dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
    tl.ebt_time.should == Time.from_minutes(20)
  end

  it "actual take off date_time dates are after dept_date_act_gmt if take off time is less than depart time" do
    dept_date_act_gmt = Date.new(1900,1,1)
    tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days,:t_o_time_act_gmt=>20,:dept_time_act_gmt=>1420)
    tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900,1,2,0,20,0)
  end

 it "actual take off date_time dates are the same as dept_date_act_gmt if take off time is not less than depart time" do
    dept_date_act_gmt = Date.new(1900,1,1)
    tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days,:t_o_time_act_gmt=>40,:dept_time_act_gmt=>20)
    tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900,1,1,0,40,0)
 end

  it "actual landing date_time dates are before arr_date_act_gmt if on time time is greater than landing time" do
    arr_date_act_gmt = Date.new(1900,1,2)
    tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days,:land_time_act_gmt=>1420,:arriv_time_act_gmt=>20)
    tl.actual_land_date_time_gmt.should == DateTime.new(1900,1,1,23,40,0)
  end

  it "actual landing date_time dates are the same as arr_date_act_gmt if on time time is not greater than landing time" do
    arr_date_act_gmt = Date.new(1900,1,2)
    tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days,:land_time_act_gmt=>20,:arriv_time_act_gmt=>40)
    tl.actual_land_date_time_gmt.should == DateTime.new(1900,1,2,0,20,0)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fossil-0.3.32 spec/models/trip_leg_spec.rb
fossil-0.3.31 spec/models/trip_leg_spec.rb