Sha256: 648432fcf8bc5f18336af44e05166347c56aedea9fe479f83d7628c94b8943b7

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'earth/air/flight_distance_class'

describe FlightDistanceClass do
  describe "when importing data", :data_miner => true do
    before do
      Earth.init :air, :load_data_miner => true, :skip_parent_associations => :true
    end
    
    it "imports all naics codes" do
      FlightDistanceClass.run_data_miner!
    end
  end
  
  describe "verify imported data", :sanity => true do
    it "should have all the data" do
      FlightDistanceClass.count.should == 2
    end
    
    it "should have distances > 0" do
      FlightDistanceClass.where('distance <= 0 OR distance IS NULL').count.should == 0
    end
    
    it "the smallest min distance should be 0" do
      FlightDistanceClass.all.map(&:min_distance).min.should == 0
    end
    
    it "the largest max distance should be half the earth's circumference" do
      FlightDistanceClass.all.map(&:max_distance).max.should == 20037.6
    end
  end
  
  describe ".find_by_distance" do
    it "should return a distance class where min distance > distance and max distance <= distance" do
      distance_class = FlightDistanceClass.find_by_distance(3700)
      distance_class.min_distance.should < 3700
      distance_class.max_distance.should >= 3700
    end
    
    it "should return nil unless distance between 0 and half the earth's circumference" do
      FlightDistanceClass.find_by_distance(-1000).should be_nil
      FlightDistanceClass.find_by_distance(0).should be_nil
      FlightDistanceClass.find_by_distance(20037.61).should be_nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
earth-0.12.4 spec/earth/air/flight_distance_class_spec.rb
earth-0.12.3 spec/earth/air/flight_distance_class_spec.rb
earth-0.12.2 spec/earth/air/flight_distance_class_spec.rb
earth-0.12.1 spec/earth/air/flight_distance_class_spec.rb
earth-0.12.0 spec/earth/air/flight_distance_class_spec.rb
earth-0.11.20 spec/earth/air/flight_distance_class_spec.rb
earth-0.11.19 spec/earth/air/flight_distance_class_spec.rb