Sha256: cd1a89d604e36ece0f2cafcd2ee8f334e6bf7980d566c54886106ab98ce76574

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'
require 'earth/industry/mecs_ratio'

describe MecsRatio do
  before :all do
    MecsRatio.auto_upgrade!
  end

  describe '.find_by_naics_code_and_census_region' do
    before do
      MecsRatio.create! :naics_code => '312', :census_region => '1', :consumption_per_dollar_of_shipments => 11
      MecsRatio.create! :naics_code => '3121', :census_region => '1', :consumption_per_dollar_of_shipments => 12
      MecsRatio.create! :naics_code => '3122', :census_region => '1', :consumption_per_dollar_of_shipments => 13
      MecsRatio.create! :naics_code => '312', :census_region => '2', :consumption_per_dollar_of_shipments => 17
      MecsRatio.create! :naics_code => '3121', :census_region => '2', :consumption_per_dollar_of_shipments => 18
      MecsRatio.create! :naics_code => '3122', :census_region => '2', :consumption_per_dollar_of_shipments => 19
      MecsRatio.create! :naics_code => '312211', :census_region => '2', :consumption_per_dollar_of_shipments => 20
    end
    it 'finds an exact match' do
      MecsRatio.find_by_naics_code_and_census_region('312211', '2').
        naics_code.should == '312211'
    end
    it 'finds a parent category by prefix' do
      MecsRatio.find_by_naics_code_and_census_region('312199', '2').
        naics_code.should == '3121'
    end
    it 'returns nil if no match found' do
      MecsRatio.find_by_naics_code_and_census_region('543211', '2').
        should be_nil
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
earth-0.11.10 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.9 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.8 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.7 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.6 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.5 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.4 spec/earth/industry/mecs_ratio_spec.rb
earth-0.11.3 spec/earth/industry/mecs_ratio_spec.rb