earth 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -21
- data/data/rail/ntd_companies.csv +1 -0
- data/data/rail/ntd_fuel_consumption.csv +1 -0
- data/data/rail/ntd_modes.csv +1 -0
- data/data/rail/ntd_service.csv +1 -0
- data/errata/flight_segment/bts_errata.csv +6 -0
- data/lib/earth.rb +1 -0
- data/lib/earth/air/aircraft.rb +3 -5
- data/lib/earth/air/airline.rb +2 -3
- data/lib/earth/air/airport.rb +4 -5
- data/lib/earth/air/bts_aircraft.rb +1 -1
- data/lib/earth/air/flight_distance_class.rb +0 -1
- data/lib/earth/air/flight_distance_class/data_miner.rb +0 -4
- data/lib/earth/air/flight_distance_class_seat_class.rb +0 -1
- data/lib/earth/air/flight_segment.rb +12 -13
- data/lib/earth/air/flight_segment/data_miner.rb +13 -0
- data/lib/earth/automobile/automobile_activity_year.rb +0 -1
- data/lib/earth/automobile/automobile_activity_year_type.rb +4 -4
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +1 -2
- data/lib/earth/automobile/automobile_fuel.rb +1 -2
- data/lib/earth/automobile/automobile_make.rb +0 -1
- data/lib/earth/automobile/automobile_make/data_miner.rb +2 -0
- data/lib/earth/automobile/automobile_make_model.rb +1 -2
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +0 -1
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +2 -223
- data/lib/earth/automobile/automobile_make_model_year_variant/parser.rb +224 -0
- data/lib/earth/automobile/automobile_make_year_fleet.rb +0 -1
- data/lib/earth/automobile/automobile_model.rb +0 -1
- data/lib/earth/automobile/automobile_size_class.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel_control.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel_year.rb +4 -4
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +7 -15
- data/lib/earth/automobile/automobile_year.rb +0 -1
- data/lib/earth/bus/bus_class.rb +0 -1
- data/lib/earth/bus/bus_fuel.rb +1 -72
- data/lib/earth/bus/bus_fuel_control.rb +0 -1
- data/lib/earth/bus/bus_fuel_control/data_miner.rb +0 -2
- data/lib/earth/bus/bus_fuel_year_control.rb +0 -1
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +0 -2
- data/lib/earth/computation/computation_carrier.rb +1 -11
- data/lib/earth/computation/computation_carrier_instance_class.rb +4 -25
- data/lib/earth/computation/computation_carrier_region.rb +0 -1
- data/lib/earth/computation/computation_carrier_region/data_miner.rb +0 -3
- data/lib/earth/diet/diet_class.rb +0 -1
- data/lib/earth/diet/food_group.rb +1 -1
- data/lib/earth/electricity/electric_market.rb +2 -0
- data/lib/earth/electricity/electric_utility.rb +11 -4
- data/lib/earth/electricity/electric_utility/data_miner.rb +2 -8
- data/lib/earth/electricity/green_button_adoption.rb +2 -1
- data/lib/earth/fuel/fuel.rb +20 -81
- data/lib/earth/fuel/fuel_year.rb +0 -44
- data/lib/earth/fuel/greenhouse_gas.rb +0 -40
- data/lib/earth/hospitality/lodging_class.rb +0 -1
- data/lib/earth/industry/cbecs_energy_intensity.rb +25 -29
- data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +1 -1
- data/lib/earth/industry/industry.rb +1 -2
- data/lib/earth/industry/mecs_energy.rb +9 -10
- data/lib/earth/industry/mecs_ratio.rb +2 -1
- data/lib/earth/industry/merchant_category.rb +1 -0
- data/lib/earth/industry/naics_2002.rb +2 -0
- data/lib/earth/industry/naics_2002_naics_2007_concordance.rb +1 -0
- data/lib/earth/industry/naics_2002_sic_1987_concordance.rb +1 -0
- data/lib/earth/industry/naics_2007.rb +1 -0
- data/lib/earth/industry/sic_1987.rb +1 -0
- data/lib/earth/locality/census_division.rb +1 -3
- data/lib/earth/locality/climate_division.rb +0 -1
- data/lib/earth/locality/country.rb +1 -2
- data/lib/earth/locality/country/data_miner.rb +4 -0
- data/lib/earth/locality/egrid_country.rb +0 -1
- data/lib/earth/locality/egrid_region.rb +1 -3
- data/lib/earth/locality/egrid_subregion.rb +1 -3
- data/lib/earth/locality/electricity_mix.rb +2 -4
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +0 -1
- data/lib/earth/locality/state.rb +0 -1
- data/lib/earth/locality/zip_code.rb +0 -1
- data/lib/earth/model.rb +1 -1
- data/lib/earth/pet/breed.rb +0 -1
- data/lib/earth/pet/breed_gender.rb +0 -1
- data/lib/earth/pet/gender.rb +0 -1
- data/lib/earth/pet/species.rb +1 -3
- data/lib/earth/rail/country_rail_class.rb +0 -1
- data/lib/earth/rail/country_rail_traction.rb +0 -1
- data/lib/earth/rail/country_rail_traction_class.rb +0 -1
- data/lib/earth/rail/national_transit_database_company.rb +1 -3
- data/lib/earth/rail/national_transit_database_company/data_miner.rb +1 -1
- data/lib/earth/rail/national_transit_database_mode.rb +0 -1
- data/lib/earth/rail/national_transit_database_mode/data_miner.rb +1 -1
- data/lib/earth/rail/national_transit_database_record.rb +0 -1
- data/lib/earth/rail/national_transit_database_record/data_miner.rb +2 -2
- data/lib/earth/rail/rail_class.rb +0 -1
- data/lib/earth/rail/rail_class/data_miner.rb +5 -4
- data/lib/earth/rail/rail_company.rb +0 -1
- data/lib/earth/rail/rail_fuel.rb +0 -1
- data/lib/earth/rail/rail_traction.rb +0 -1
- data/lib/earth/rail/rail_traction/data_miner.rb +2 -8
- data/lib/earth/residence/air_conditioner_use.rb +0 -1
- data/lib/earth/residence/clothes_machine_use.rb +0 -1
- data/lib/earth/residence/dishwasher_use.rb +0 -1
- data/lib/earth/residence/residence_appliance.rb +0 -1
- data/lib/earth/residence/residence_class.rb +0 -1
- data/lib/earth/residence/residence_fuel_price.rb +1 -2
- data/lib/earth/residence/urbanity.rb +0 -1
- data/lib/earth/shipping/carrier.rb +1 -52
- data/lib/earth/shipping/carrier_mode.rb +0 -34
- data/lib/earth/shipping/shipment_mode.rb +0 -26
- data/lib/earth/tasks.rb +14 -4
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +9 -1
- data/spec/earth/air/airline_spec.rb +2 -2
- data/spec/earth/air/airport_spec.rb +1 -2
- data/spec/earth/air/bts_aircraft_spec.rb +2 -2
- data/spec/earth/air/flight_distance_class_seat_class_spec.rb +22 -0
- data/spec/earth/air/flight_distance_class_spec.rb +26 -18
- data/spec/earth/air/flight_seat_class_spec.rb +12 -0
- data/spec/earth/air/flight_segment_spec.rb +38 -33
- data/spec/earth/automobile/automobile_activity_year_spec.rb +20 -14
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +14 -10
- data/spec/earth/automobile/automobile_activity_year_type_spec.rb +28 -20
- data/spec/earth/automobile/automobile_fuel_spec.rb +106 -52
- data/spec/earth/automobile/automobile_make_model_spec.rb +103 -62
- data/spec/earth/automobile/automobile_make_model_year_spec.rb +69 -46
- data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +108 -109
- data/spec/earth/automobile/automobile_make_spec.rb +8 -8
- data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +10 -6
- data/spec/earth/automobile/automobile_make_year_spec.rb +10 -9
- data/spec/earth/automobile/automobile_model_spec.rb +3 -0
- data/spec/earth/automobile/automobile_size_class_spec.rb +12 -11
- data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +9 -9
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +23 -18
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +37 -29
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +35 -36
- data/spec/earth/automobile/automobile_year_spec.rb +4 -2
- data/spec/earth/bus/bus_class_spec.rb +10 -0
- data/spec/earth/bus/bus_fuel_control_spec.rb +3 -5
- data/spec/earth/bus/bus_fuel_spec.rb +16 -8
- data/spec/earth/bus/bus_fuel_year_control_spec.rb +7 -7
- data/spec/earth/computation/computation_carrrier_instance_class_spec.rb +17 -0
- data/spec/earth/computation/computation_carrrier_region_spec.rb +10 -0
- data/spec/earth/computation/computation_carrrier_spec.rb +17 -0
- data/spec/earth/diet/diet_class_spec.rb +14 -0
- data/spec/earth/diet/food_group_spec.rb +26 -0
- data/spec/earth/electricity/electric_market_spec.rb +4 -5
- data/spec/earth/electricity/electric_utility_spec.rb +30 -19
- data/spec/earth/electricity/green_button_adoption_spec.rb +29 -7
- data/spec/earth/fuel/fuel_spec.rb +88 -14
- data/spec/earth/fuel/fuel_year_spec.rb +21 -0
- data/spec/earth/fuel/greenhouse_gas_spec.rb +23 -0
- data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +13 -10
- data/spec/earth/hospitality/lodging_class_spec.rb +1 -1
- data/spec/earth/industry/cbecs_energy_intensity_spec.rb +72 -72
- data/spec/earth/industry/industry_spec.rb +16 -9
- data/spec/earth/industry/mecs_energy_spec.rb +76 -72
- data/spec/earth/industry/mecs_ratio_spec.rb +35 -31
- data/spec/earth/industry/merchant_category_spec.rb +7 -5
- data/spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb +10 -19
- data/spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb +9 -19
- data/spec/earth/industry/naics_2002_spec.rb +1 -11
- data/spec/earth/industry/naics_2007_spec.rb +2 -11
- data/spec/earth/industry/sic_1987_spec.rb +3 -14
- data/spec/earth/locality/census_division_spec.rb +25 -0
- data/spec/earth/locality/census_region_spec.rb +8 -0
- data/spec/earth/locality/climate_division_spec.rb +13 -0
- data/spec/earth/locality/country_spec.rb +24 -23
- data/spec/earth/locality/egrid_country_spec.rb +7 -6
- data/spec/earth/locality/egrid_region_spec.rb +6 -6
- data/spec/earth/locality/egrid_subregion_spec.rb +14 -14
- data/spec/earth/locality/electricity_mix_spec.rb +17 -17
- data/spec/earth/locality/padd_spec.rb +21 -0
- data/spec/earth/locality/state_spec.rb +8 -11
- data/spec/earth/locality/zip_code_spec.rb +29 -22
- data/spec/earth/pet/breed_gender_spec.rb +8 -0
- data/spec/earth/pet/breed_spec.rb +8 -0
- data/spec/earth/pet/gender_spec.rb +8 -0
- data/spec/earth/pet/species_spec.rb +11 -5
- data/spec/earth/rail/country_rail_class_spec.rb +16 -0
- data/spec/earth/rail/country_rail_traction_class_spec.rb +14 -0
- data/spec/earth/rail/country_rail_traction_spec.rb +14 -0
- data/spec/earth/rail/national_transit_database_company_spec.rb +103 -0
- data/spec/earth/rail/national_transit_database_mode_spec.rb +21 -0
- data/spec/earth/rail/national_transit_database_record_spec.rb +31 -0
- data/spec/earth/rail/rail_class_spec.rb +8 -0
- data/spec/earth/rail/rail_company_spec.rb +20 -0
- data/spec/earth/rail/rail_fuel_spec.rb +19 -0
- data/spec/earth/rail/rail_traction_spec.rb +8 -0
- data/spec/earth/residence/air_conditioner_use_spec.rb +17 -0
- data/spec/earth/residence/clothes_machine_use_spec.rb +11 -0
- data/spec/earth/residence/dishwasher_use_spec.rb +11 -0
- data/spec/earth/residence/residence_appliance_spec.rb +19 -0
- data/spec/earth/residence/residence_class_spec.rb +15 -0
- data/spec/earth/residence/residence_fuel_price_spec.rb +12 -0
- data/spec/earth/residence/residence_fuel_type_spec.rb +18 -0
- data/spec/earth/residence/residential_energy_consumption_survey_response_spec.rb +13 -0
- data/spec/earth/residence/urbanity_spec.rb +8 -0
- data/spec/earth/shipping/carrier_mode_spec.rb +18 -0
- data/spec/earth/shipping/carrier_spec.rb +27 -0
- data/spec/earth/shipping/shipment_mode_spec.rb +16 -0
- data/spec/earth_spec.rb +1 -1
- data/spec/factories/airline.rb +0 -1
- data/spec/factories/airport.rb +0 -1
- data/spec/factories/automobile_activity_year.rb +8 -0
- data/spec/factories/automobile_activity_year_type.rb +8 -0
- data/spec/factories/automobile_activity_year_type_fuel.rb +9 -0
- data/spec/factories/automobile_fuel.rb +15 -0
- data/spec/factories/automobile_make.rb +9 -0
- data/spec/factories/automobile_make_model.rb +10 -0
- data/spec/factories/automobile_make_model_year.rb +9 -0
- data/spec/factories/automobile_model.rb +9 -0
- data/spec/factories/automobile_type_fuel.rb +7 -0
- data/spec/factories/automobile_type_fuel_control.rb +16 -0
- data/spec/factories/automobile_type_fuel_year.rb +9 -0
- data/spec/factories/automobile_type_fuel_year_control.rb +11 -0
- data/spec/factories/bus_fuel.rb +7 -0
- data/spec/factories/bus_fuel_year_control.rb +9 -0
- data/spec/factories/cbecs_energy_intensity.rb +15 -0
- data/spec/factories/commercial_building_energy_consumption_survey_response.rb +10 -0
- data/spec/factories/electric_utility.rb +8 -0
- data/spec/factories/flight_distance_class.rb +8 -0
- data/spec/factories/flight_segment.rb +0 -1
- data/spec/factories/food_group.rb +8 -0
- data/spec/factories/fuel.rb +8 -0
- data/spec/factories/fuel_year.rb +8 -0
- data/spec/factories/green_button_adoption.rb +8 -0
- data/spec/factories/greenhouse_gas.rb +7 -0
- data/spec/factories/industry.rb +9 -0
- data/spec/factories/mecs_energy.rb +15 -0
- data/spec/factories/mecs_ratio.rb +15 -0
- data/spec/factories/national_transit_database_company.rb +8 -0
- data/spec/factories/national_transit_database_mode.rb +8 -0
- data/spec/factories/national_transit_database_record.rb +9 -0
- data/spec/factories/residence_appliance.rb +7 -0
- data/spec/factories/zip_code.rb +9 -0
- data/spec/spec_helper.rb +36 -19
- metadata +346 -66
- data/lib/earth/acronyms.rb +0 -12
- data/lib/earth/rail/rail_company_traction.rb +0 -24
- data/lib/earth/rail/rail_company_traction/data_miner.rb +0 -4
- data/lib/earth/rail/rail_company_traction_class.rb +0 -26
- data/lib/earth/rail/rail_company_traction_class/data_miner.rb +0 -4
@@ -2,81 +2,104 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/automobile/automobile_make_model_year'
|
3
3
|
|
4
4
|
describe AutomobileMakeModelYear do
|
5
|
-
|
6
|
-
|
7
|
-
end
|
5
|
+
let(:ammy) { AutomobileMakeModelYear }
|
6
|
+
let(:ammyv) { AutomobileMakeModelYearVariant }
|
8
7
|
|
9
|
-
describe '
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
describe 'Sanity check', :sanity => true do
|
9
|
+
# confirm we have right data from all years
|
10
|
+
it { ammy.where(:year => 1985).count.should == 360 }
|
11
|
+
it { ammy.where(:year => 1986).count.should == 350 }
|
12
|
+
it { ammy.where(:year => 1987).count.should == 385 }
|
13
|
+
it { ammy.where(:year => 1988).count.should == 370 }
|
14
|
+
it { ammy.where(:year => 1989).count.should == 373 }
|
15
|
+
it { ammy.where(:year => 1990).count.should == 349 }
|
16
|
+
it { ammy.where(:year => 1991).count.should == 363 }
|
17
|
+
it { ammy.where(:year => 1992).count.should == 337 }
|
18
|
+
it { ammy.where(:year => 1993).count.should == 322 }
|
19
|
+
it { ammy.where(:year => 1994).count.should == 318 }
|
20
|
+
it { ammy.where(:year => 1995).count.should == 320 }
|
21
|
+
it { ammy.where(:year => 1996).count.should == 286 }
|
22
|
+
it { ammy.where(:year => 1997).count.should == 277 }
|
23
|
+
it { ammy.where(:year => 1998).count.should == 301 }
|
24
|
+
it { ammy.where(:year => 1999).count.should == 308 }
|
25
|
+
it { ammy.where(:year => 2000).count.should == 320 }
|
26
|
+
it { ammy.where(:year => 2001).count.should == 341 }
|
27
|
+
it { ammy.where(:year => 2002).count.should == 377 }
|
28
|
+
it { ammy.where(:year => 2003).count.should == 410 }
|
29
|
+
it { ammy.where(:year => 2004).count.should == 437 }
|
30
|
+
it { ammy.where(:year => 2005).count.should == 445 }
|
31
|
+
it { ammy.where(:year => 2006).count.should == 431 }
|
32
|
+
it { ammy.where(:year => 2007).count.should == 499 }
|
33
|
+
it { ammy.where(:year => 2008).count.should == 539 }
|
34
|
+
it { ammy.where(:year => 2009).count.should == 496 }
|
35
|
+
it { ammy.where(:year => 2010).count.should == 530 }
|
36
|
+
it { ammy.where(:year => 2011).count.should == 562 }
|
37
|
+
it { ammy.where(:year => 2012).count.should == 591 }
|
15
38
|
|
16
39
|
# confirm make, model, year aren't missing
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
40
|
+
it { ammy.where(:make_name => nil).count.should == 0 }
|
41
|
+
it { ammy.where(:model_name => nil).count.should == 0 }
|
42
|
+
it { ammy.where(:year => nil).count.should == 0 }
|
20
43
|
|
21
44
|
it 'should have valid fuel codes' do
|
22
|
-
|
23
|
-
fail "#{code} is not a valid code" unless
|
45
|
+
ammy.connection.select_values("SELECT DISTINCT fuel_code FROM #{ammy.quoted_table_name} WHERE fuel_code != 'G'").each do |code|
|
46
|
+
fail "#{code} is not a valid code" unless ammyv::Parser::FUEL_CODES.values.include?(code)
|
24
47
|
end
|
25
48
|
end
|
26
49
|
|
27
50
|
it 'should have valid alt fuel codes' do
|
28
|
-
|
29
|
-
fail "#{code} is not a valid code" unless
|
51
|
+
ammy.connection.select_values("SELECT DISTINCT alt_fuel_code FROM #{ammy.quoted_table_name} WHERE alt_fuel_code IS NOT NULL").each do |code|
|
52
|
+
fail "#{code} is not a valid code" unless ammyv::Parser::FUEL_CODES.values.include?(code)
|
30
53
|
end
|
31
54
|
end
|
32
55
|
|
33
|
-
it {
|
56
|
+
it { ammy.where(:hybridity => true).count.should == 170 }
|
34
57
|
|
35
58
|
it 'should have proper weightings' do
|
36
|
-
|
37
|
-
|
59
|
+
ammy.connection.select_values("SELECT DISTINCT year FROM #{ammy.quoted_table_name}").each do |year|
|
60
|
+
ammy.where(:year => year).first.weighting.should == AutomobileYear.weighting(year)
|
38
61
|
end
|
39
62
|
end
|
40
63
|
|
41
64
|
# confirm fuel efficiencies are valid and proper units
|
42
|
-
it {
|
43
|
-
it {
|
44
|
-
it {
|
45
|
-
it {
|
65
|
+
it { ammy.where("fuel_efficiency_city > 0").count.should == ammy.count }
|
66
|
+
it { ammy.where("fuel_efficiency_highway > 0").count.should == ammy.count }
|
67
|
+
it { ammy.where(:fuel_efficiency_city_units => 'kilometres_per_litre').count.should == ammy.count }
|
68
|
+
it { ammy.where(:fuel_efficiency_highway_units => 'kilometres_per_litre').count.should == ammy.count }
|
46
69
|
|
47
70
|
# confirm alt fuel efficiencies are valid and proper units
|
48
|
-
it {
|
49
|
-
it {
|
50
|
-
it {
|
51
|
-
it {
|
71
|
+
it { ammy.where("alt_fuel_efficiency_city > 0").count.should == ammy.where("alt_fuel_code IS NOT NULL").count }
|
72
|
+
it { ammy.where("alt_fuel_efficiency_highway > 0").count.should == ammy.where("alt_fuel_code IS NOT NULL").count }
|
73
|
+
it { ammy.where(:alt_fuel_efficiency_city_units => 'kilometres_per_litre').count.should == ammy.where("alt_fuel_code IS NOT NULL").count }
|
74
|
+
it { ammy.where(:alt_fuel_efficiency_highway_units => 'kilometres_per_litre').count.should == ammy.where("alt_fuel_code IS NOT NULL").count }
|
52
75
|
|
53
76
|
# # spot check fuel efficiency calcs
|
54
|
-
it {
|
55
|
-
it {
|
77
|
+
it { ammy.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_city.should be_within(0.0001).of(14.8800) }
|
78
|
+
it { ammy.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_highway.should be_within(0.0001).of(17.0057) }
|
56
79
|
|
57
|
-
it {
|
58
|
-
it {
|
80
|
+
it { ammy.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_city.should be_within(0.0001).of(40.3887) }
|
81
|
+
it { ammy.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(39.5384) }
|
59
82
|
|
60
|
-
it {
|
61
|
-
it {
|
83
|
+
it { ammy.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_city.should be_within(0.0001).of(14.8800) }
|
84
|
+
it { ammy.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_highway.should be_within(0.0001).of(17.0057) }
|
62
85
|
|
63
|
-
it {
|
64
|
-
it {
|
86
|
+
it { ammy.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_city.should be_within(0.0001).of(40.3887) }
|
87
|
+
it { ammy.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(38.2629) }
|
65
88
|
|
66
|
-
it {
|
67
|
-
it {
|
89
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).fuel_efficiency_city.should be_within(0.0001).of( 8.0777) }
|
90
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).fuel_efficiency_highway.should be_within(0.0001).of(11.4789) }
|
68
91
|
|
69
|
-
it {
|
70
|
-
it {
|
92
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).alt_fuel_efficiency_city.should be_within(0.0001).of(5.9520) }
|
93
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(8.5029) }
|
71
94
|
|
72
|
-
it {
|
73
|
-
it {
|
95
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER'}).fuel_efficiency_city.should be_within(0.0001).of(7.86516) }
|
96
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER'}).fuel_efficiency_highway.should be_within(0.0001).of(12.11660) }
|
74
97
|
|
75
|
-
it {
|
76
|
-
it {
|
98
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER'}).alt_fuel_efficiency_city.should == nil }
|
99
|
+
it { ammy.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER'}).alt_fuel_efficiency_highway.should == nil }
|
77
100
|
|
78
|
-
it {
|
79
|
-
it {
|
80
|
-
it {
|
101
|
+
it { ammy.where(:type_name => nil).count.should == 0 }
|
102
|
+
it { ammy.find(:first, :conditions => {:make_name => 'Toyota', :model_name => 'Prius'}).type_name.should == 'Passenger cars' }
|
103
|
+
it { ammy.find(:first, :conditions => {:make_name => 'Toyota', :model_name => 'Highlander'}).type_name.should == 'Light-duty trucks' }
|
81
104
|
end
|
82
105
|
end
|
@@ -3,180 +3,179 @@ require 'spec_helper'
|
|
3
3
|
require 'earth/automobile/automobile_make_model_year_variant'
|
4
4
|
|
5
5
|
describe AutomobileMakeModelYearVariant do
|
6
|
-
|
7
|
-
require 'earth/acronyms'
|
8
|
-
end
|
6
|
+
let(:ammyv) { AutomobileMakeModelYearVariant }
|
9
7
|
|
10
|
-
describe '
|
8
|
+
describe 'Sanity check', :sanity => true do
|
11
9
|
# confirm we have right data from all years
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
10
|
+
it { ammyv.where(:year => 1985).count.should == 1152 }
|
11
|
+
it { ammyv.where(:year => 1986).count.should == 1183 }
|
12
|
+
it { ammyv.where(:year => 1987).count.should == 1206 }
|
13
|
+
it { ammyv.where(:year => 1988).count.should == 1104 }
|
14
|
+
it { ammyv.where(:year => 1989).count.should == 1137 }
|
15
|
+
it { ammyv.where(:year => 1990).count.should == 1049 }
|
16
|
+
it { ammyv.where(:year => 1991).count.should == 1062 }
|
17
|
+
it { ammyv.where(:year => 1992).count.should == 1055 }
|
18
|
+
it { ammyv.where(:year => 1993).count.should == 986 }
|
19
|
+
it { ammyv.where(:year => 1994).count.should == 963 }
|
20
|
+
it { ammyv.where(:year => 1995).count.should == 917 }
|
21
|
+
it { ammyv.where(:year => 1996).count.should == 750 }
|
22
|
+
it { ammyv.where(:year => 1997).count.should == 727 }
|
23
|
+
it { ammyv.where(:year => 1998).count.should == 794 }
|
24
|
+
it { ammyv.where(:year => 1999).count.should == 800 }
|
25
|
+
it { ammyv.where(:year => 2000).count.should == 834 }
|
26
|
+
it { ammyv.where(:year => 2001).count.should == 846 }
|
27
|
+
it { ammyv.where(:year => 2002).count.should == 933 }
|
28
|
+
it { ammyv.where(:year => 2003).count.should == 995 }
|
29
|
+
it { ammyv.where(:year => 2004).count.should == 1091 }
|
30
|
+
it { ammyv.where(:year => 2005).count.should == 1069 }
|
31
|
+
it { ammyv.where(:year => 2006).count.should == 1043 }
|
32
|
+
it { ammyv.where(:year => 2007).count.should == 1126 }
|
33
|
+
it { ammyv.where(:year => 2008).count.should == 1186 }
|
34
|
+
it { ammyv.where(:year => 2009).count.should == 1092 }
|
35
|
+
it { ammyv.where(:year => 2010).count.should == 1107 }
|
36
|
+
it { ammyv.where(:year => 2011).count.should == 1097 }
|
37
|
+
it { ammyv.where(:year => 2012).count.should == 1129 }
|
40
38
|
|
41
39
|
# confirm make, model, year, size class, and type aren't missing
|
42
|
-
it {
|
43
|
-
it {
|
44
|
-
it {
|
45
|
-
it {
|
46
|
-
it {
|
40
|
+
it { ammyv.where(:make_name => nil).count.should == 0 }
|
41
|
+
it { ammyv.where(:model_name => nil).count.should == 0 }
|
42
|
+
it { ammyv.where(:year => nil).count.should == 0 }
|
43
|
+
it { ammyv.where(:size_class => nil).count.should == 0 }
|
44
|
+
it { ammyv.where(:type_name => nil).count.should == 0 }
|
47
45
|
|
48
46
|
# confirm it handles special characters
|
49
|
-
it {
|
47
|
+
it { ammyv.where(:make_name => 'Citroën').count.should > 13 }
|
50
48
|
|
51
49
|
# confirm Chevy and GMC model names have been simplified
|
52
|
-
it {
|
50
|
+
it { ammyv.where("make_name IN ('Chevrolet', 'GMC') AND model_name REGEXP '^[CK][0-9]+'").count.should == 0 }
|
53
51
|
|
54
52
|
# confirm certain hybrids have been identified
|
55
|
-
it {
|
56
|
-
it {
|
57
|
-
it {
|
58
|
-
it {
|
53
|
+
it { ammyv.where(:year => 2012, :make_name => 'Buick', :model_name => 'LACROSSE HYBRID').count.should == 1 }
|
54
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Buick', :model_name => 'LACROSSE HYBRID'}).fuel_efficiency.should be_within(1e-4).of(12.8701) }
|
55
|
+
it { ammyv.where(:year => 2012, :make_name => 'Buick', :model_name => 'REGAL HYBRID').count.should == 1 }
|
56
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Buick', :model_name => 'REGAL HYBRID'}).fuel_efficiency.should be_within(1e-4).of(12.8701) }
|
59
57
|
|
60
58
|
# confirm dual-fuel and CNG variants have been merged and identified
|
61
|
-
it {
|
62
|
-
it {
|
63
|
-
it {
|
59
|
+
it { ammyv.where(:make_name => 'Chevrolet', :model_name => 'CAVALIER DUAL-FUEL', :fuel_code => 'C').count.should == 0 }
|
60
|
+
it { ammyv.where(:make_name => 'Chevrolet', :model_name => 'CAVALIER DUAL-FUEL', :fuel_code => 'R', :alt_fuel_code => 'C').count.should == 5 }
|
61
|
+
it { ammyv.where(:fuel_code => 'C').count.should == ammyv.where("model_name LIKE '%CNG'").count }
|
64
62
|
|
65
63
|
# confirm FFV variants have been merged
|
66
|
-
it {
|
67
|
-
it {
|
64
|
+
it { ammyv.where(:fuel_code => 'E').count.should == 0 }
|
65
|
+
it { ammyv.where(:alt_fuel_code => 'E').count.should > 750 }
|
68
66
|
|
69
67
|
# confirm flex-fuel variants of models where not all variants are flex-fuel have been identified
|
70
|
-
it {
|
71
|
-
it {
|
72
|
-
it {
|
68
|
+
it { ammyv.where("model_name LIKE '%FFV'").count.should > 700 }
|
69
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Toyota', :model_name => 'SEQUOIA FFV'}).alt_fuel_code.should == 'E' }
|
70
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Toyota', :model_name => 'SEQUOIA'}).alt_fuel_code.should == nil }
|
73
71
|
|
74
72
|
# confirm diesel variants of models where not all variants are diesel have been identified
|
75
|
-
it {
|
76
|
-
it {
|
77
|
-
it {
|
73
|
+
it { ammyv.where("model_name LIKE '%DIESEL'").count.should > 575 }
|
74
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Volkswagen', :model_name => 'JETTA DIESEL'}).fuel_code.should == 'D' }
|
75
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Volkswagen', :model_name => 'JETTA'}).fuel_code.should_not == 'D' }
|
78
76
|
|
79
77
|
it "type name shouldn't vary within a make model" do
|
80
|
-
|
78
|
+
ammyv.connection.select_values(%{
|
81
79
|
SELECT * FROM
|
82
80
|
(SELECT make_name, model_name, GROUP_CONCAT(DISTINCT type_name) AS types
|
83
|
-
FROM #{
|
81
|
+
FROM #{ammyv.quoted_table_name}
|
84
82
|
GROUP BY make_name, model_name) AS t1
|
85
83
|
WHERE types LIKE '%,%'
|
86
84
|
}).count.should == 0
|
87
85
|
end
|
88
86
|
|
89
87
|
it 'should have valid transmissions' do
|
90
|
-
|
91
|
-
fail "#{transmission} is not a valid transmission" unless
|
88
|
+
ammyv.connection.select_values("SELECT DISTINCT transmission FROM #{ammyv.quoted_table_name}").each do |transmission|
|
89
|
+
fail "#{transmission} is not a valid transmission" unless AutomobileMakeModelYearVariant::Parser::TRANSMISSIONS.values.include?(transmission)
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
95
93
|
it 'should have valid speeds' do
|
96
94
|
valid_speeds = ["1", "3", "4", "5", "6", "7", "8", "variable"]
|
97
|
-
|
95
|
+
ammyv.connection.select_values("SELECT DISTINCT speeds FROM #{ammyv.quoted_table_name}").each do |speeds|
|
98
96
|
fail "#{speeds} is not a valid speeds" unless valid_speeds.include?(speeds)
|
99
97
|
end
|
100
98
|
end
|
101
99
|
|
102
100
|
it 'should have valid drives' do
|
103
101
|
valid_drives = ["FWD", "RWD", "4WD", "AWD", "PWD"] # PWD = part-time 4-wheel drive
|
104
|
-
|
102
|
+
ammyv.connection.select_values("SELECT DISTINCT drive FROM #{ammyv.quoted_table_name}").each do |drive|
|
105
103
|
fail "#{drive} is not a valid drive" unless valid_drives.include?(drive)
|
106
104
|
end
|
107
105
|
end
|
108
106
|
|
109
107
|
it 'should have valid fuel codes' do
|
110
|
-
|
111
|
-
fail "#{code} is not a valid code" unless
|
108
|
+
ammyv.connection.select_values("SELECT DISTINCT fuel_code FROM #{ammyv.quoted_table_name}").each do |code|
|
109
|
+
fail "#{code} is not a valid code" unless AutomobileMakeModelYearVariant::Parser::FUEL_CODES.values.include?(code)
|
112
110
|
end
|
113
111
|
end
|
114
112
|
|
115
113
|
it 'should have valid alt fuel codes' do
|
116
|
-
|
117
|
-
fail "#{code} is not a valid code" unless
|
114
|
+
ammyv.connection.select_values("SELECT DISTINCT alt_fuel_code FROM #{ammyv.quoted_table_name} WHERE alt_fuel_code IS NOT NULL").each do |code|
|
115
|
+
fail "#{code} is not a valid code" unless AutomobileMakeModelYearVariant::Parser::FUEL_CODES.values.include?(code)
|
118
116
|
end
|
119
117
|
end
|
120
118
|
|
121
119
|
# confirm fuel efficiencies are valid and proper units
|
122
|
-
|
123
|
-
it {
|
124
|
-
it {
|
125
|
-
it {
|
126
|
-
it {
|
127
|
-
it {
|
120
|
+
let(:total) { ammyv.count }
|
121
|
+
it { ammyv.where("fuel_efficiency > 0").count.should == total }
|
122
|
+
it { ammyv.where("fuel_efficiency_city > 0").count.should == total }
|
123
|
+
it { ammyv.where("fuel_efficiency_highway > 0").count.should == total }
|
124
|
+
it { ammyv.where(:fuel_efficiency_units => 'kilometres_per_litre').count.should == total }
|
125
|
+
it { ammyv.where(:fuel_efficiency_city_units => 'kilometres_per_litre').count.should == total }
|
126
|
+
it { ammyv.where(:fuel_efficiency_highway_units => 'kilometres_per_litre').count.should == total }
|
128
127
|
|
129
128
|
# confirm alt fuel efficiencies are valid and proper units
|
130
|
-
it {
|
131
|
-
it {
|
132
|
-
it {
|
133
|
-
it {
|
134
|
-
it {
|
135
|
-
it {
|
129
|
+
it { ammyv.where("alt_fuel_efficiency > 0").count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
130
|
+
it { ammyv.where("alt_fuel_efficiency_city > 0").count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
131
|
+
it { ammyv.where("alt_fuel_efficiency_highway > 0").count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
132
|
+
it { ammyv.where(:alt_fuel_efficiency_units => 'kilometres_per_litre').count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
133
|
+
it { ammyv.where(:alt_fuel_efficiency_city_units => 'kilometres_per_litre').count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
134
|
+
it { ammyv.where(:alt_fuel_efficiency_highway_units => 'kilometres_per_litre').count.should == ammyv.where("alt_fuel_code IS NOT NULL").count }
|
136
135
|
|
137
136
|
# spot check fuel efficiency calcs
|
138
|
-
it {
|
139
|
-
it {
|
140
|
-
it {
|
137
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_city.should be_within(0.0001).of(14.8800) }
|
138
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_highway.should be_within(0.0001).of(17.0057) }
|
139
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency.should be_within(0.0001).of(16.0216) }
|
141
140
|
|
142
|
-
it {
|
143
|
-
it {
|
144
|
-
it {
|
141
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_city.should be_within(0.0001).of(40.3887) }
|
142
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(39.5384) }
|
143
|
+
it { ammyv.find(:first, :conditions => {:year => 2012, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency.should be_within(0.0001).of(39.8996) }
|
145
144
|
|
146
|
-
it {
|
147
|
-
it {
|
148
|
-
it {
|
145
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_city.should be_within(0.0001).of(14.8800) }
|
146
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency_highway.should be_within(0.0001).of(17.0057) }
|
147
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).fuel_efficiency.should be_within(0.0001).of(16.0216) }
|
149
148
|
|
150
|
-
it {
|
151
|
-
it {
|
152
|
-
it {
|
149
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_city.should be_within(0.0001).of(40.3887) }
|
150
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(38.2629) }
|
151
|
+
it { ammyv.find(:first, :conditions => {:year => 2011, :make_name => 'Chevrolet', :model_name => 'VOLT'}).alt_fuel_efficiency.should be_within(0.0001).of(39.1489) }
|
153
152
|
|
154
|
-
it {
|
155
|
-
it {
|
156
|
-
it {
|
153
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).fuel_efficiency_city.should be_within(0.0001).of( 8.0777) }
|
154
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).fuel_efficiency_highway.should be_within(0.0001).of(11.4789) }
|
155
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).fuel_efficiency.should be_within(0.0001).of( 9.7192) }
|
157
156
|
|
158
|
-
it {
|
159
|
-
it {
|
160
|
-
it {
|
157
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).alt_fuel_efficiency_city.should be_within(0.0001).of(5.9520) }
|
158
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).alt_fuel_efficiency_highway.should be_within(0.0001).of(8.5029) }
|
159
|
+
it { ammyv.find(:first, :conditions => {:year => 2010, :make_name => 'Dodge', :model_name => 'AVENGER FFV'}).alt_fuel_efficiency.should be_within(0.0001).of(7.1797) }
|
161
160
|
|
162
|
-
it {
|
163
|
-
it {
|
164
|
-
it {
|
161
|
+
it { ammyv.find(:first, :conditions => {:year => 2009, :make_name => 'Toyota', :model_name => 'PRIUS'}).fuel_efficiency_city.should be_within(0.0001).of(20.2602) }
|
162
|
+
it { ammyv.find(:first, :conditions => {:year => 2009, :make_name => 'Toyota', :model_name => 'PRIUS'}).fuel_efficiency_highway.should be_within(0.0001).of(19.1879) }
|
163
|
+
it { ammyv.find(:first, :conditions => {:year => 2009, :make_name => 'Toyota', :model_name => 'PRIUS'}).fuel_efficiency.should be_within(0.0001).of(19.6347) }
|
165
164
|
|
166
|
-
it {
|
167
|
-
it {
|
168
|
-
it {
|
165
|
+
it { ammyv.find(:first, :conditions => {:year => 1998, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency_city.should be_within(0.0001).of( 7.9773) }
|
166
|
+
it { ammyv.find(:first, :conditions => {:year => 1998, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency_highway.should be_within(0.0001).of(10.2480) }
|
167
|
+
it { ammyv.find(:first, :conditions => {:year => 1998, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency.should be_within(0.0001).of( 9.1305) }
|
169
168
|
|
170
|
-
it {
|
171
|
-
it {
|
172
|
-
it {
|
169
|
+
it { ammyv.find(:first, :conditions => {:year => 1997, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency_city.should be_within(0.0001).of( 7.7886) }
|
170
|
+
it { ammyv.find(:first, :conditions => {:year => 1997, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency_highway.should be_within(0.0001).of(10.3739) }
|
171
|
+
it { ammyv.find(:first, :conditions => {:year => 1997, :make_name => 'Honda', :model_name => 'ODYSSEY'}).fuel_efficiency.should be_within(0.0001).of( 9.0782) }
|
173
172
|
|
174
|
-
it {
|
175
|
-
it {
|
176
|
-
it {
|
173
|
+
it { ammyv.find(:first, :conditions => {:year => 1995, :make_name => 'Jaguar', :model_name => 'XJR'}).fuel_efficiency_city.should be_within(0.0001).of(5.8670) }
|
174
|
+
it { ammyv.find(:first, :conditions => {:year => 1995, :make_name => 'Jaguar', :model_name => 'XJR'}).fuel_efficiency_highway.should be_within(0.0001).of(8.2903) }
|
175
|
+
it { ammyv.find(:first, :conditions => {:year => 1995, :make_name => 'Jaguar', :model_name => 'XJR'}).fuel_efficiency.should be_within(0.0001).of(7.0399) }
|
177
176
|
|
178
|
-
it {
|
179
|
-
it {
|
180
|
-
it {
|
177
|
+
it { ammyv.find(:first, :conditions => {:year => 1985, :make_name => 'Jaguar', :model_name => 'XJ'}).fuel_efficiency_city.should be_within(0.0001).of(5.8479) }
|
178
|
+
it { ammyv.find(:first, :conditions => {:year => 1985, :make_name => 'Jaguar', :model_name => 'XJ'}).fuel_efficiency_highway.should be_within(0.0001).of(7.3958) }
|
179
|
+
it { ammyv.find(:first, :conditions => {:year => 1985, :make_name => 'Jaguar', :model_name => 'XJ'}).fuel_efficiency.should be_within(0.0001).of(6.6401) }
|
181
180
|
end
|
182
181
|
end
|
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/automobile/automobile_make'
|
3
3
|
|
4
4
|
describe AutomobileMake do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
it { AutomobileMake.where("fuel_efficiency > 0").count.should ==
|
10
|
-
it { AutomobileMake.where(:fuel_efficiency_units => 'kilometres_per_litre').count.should ==
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
let(:total) { AutomobileMake.count }
|
7
|
+
|
8
|
+
it { total.should == 81 }
|
9
|
+
it { AutomobileMake.where("fuel_efficiency > 0").count.should == total }
|
10
|
+
it { AutomobileMake.where(:fuel_efficiency_units => 'kilometres_per_litre').count.should == total }
|
11
11
|
|
12
12
|
# spot checks
|
13
|
-
it {
|
14
|
-
it {
|
13
|
+
it { AutomobileMake.find('Honda').fuel_efficiency.should be_within(1e-4).of(13.0594) } # fe from CAFE data
|
14
|
+
it { AutomobileMake.find('Acura').fuel_efficiency.should be_within(1e-4).of(9.1347) } # fe from average of variants
|
15
15
|
end
|
16
16
|
end
|