Sha256: 209b0c7d30fc5fc466c45b32ed49d1b0d75198da04215eb90fb389fc1a36b02c
Contents?: true
Size: 1.56 KB
Versions: 7
Compression:
Stored size: 1.56 KB
Contents
require 'spec_helper' require "#{Earth::FACTORY_DIR}/automobile_activity_year_type" require "#{Earth::FACTORY_DIR}/automobile_activity_year_type_fuel" describe AutomobileActivityYearType do let(:aayt) { AutomobileActivityYearType } describe '.find_by_type_name_and_closest_year' do it 'returns the AAYT with the closest year' do cars_2009 = FactoryGirl.create :aayt, :cars_2009 cars_2010 = FactoryGirl.create :aayt, :cars_2010 aayt.find_by_type_name_and_closest_year('cars', 2011).should == cars_2010 aayt.find_by_type_name_and_closest_year('cars', 2009).should == cars_2009 aayt.find_by_type_name_and_closest_year('cars', 2000).should == cars_2009 end end describe '#activity_year_type_fuels' do it 'returns activity year type fuels with the same activity year and type name' do d = FactoryGirl.create :aaytf, :diesel_car_2010 g = FactoryGirl.create :aaytf, :gas_car_2010 cars_2010 = FactoryGirl.create :aayt, :cars_2010 cars_2010.activity_year_type_fuels.should == [d,g] end end describe 'Sanity check', :sanity => true do let(:total) { aayt.count } it { total.should == 30 } it { aayt.where("hfc_emissions > 0").count.should == total } it { aayt.where("hfc_emission_factor > 0").count.should == total } # spot check it { aayt.first.hfc_emissions.should be_within(0.1).of(31000000000) } it { aayt.first.hfc_emission_factor.should be_within(1e-5).of(0.02438) } it { aayt.first.hfc_emission_factor_units.should == 'kilograms_co2e_per_kilometre' } end end
Version data entries
7 entries across 7 versions & 1 rubygems