spec/postal_code_spec.rb in govkit-ca-0.0.2 vs spec/postal_code_spec.rb in govkit-ca-0.0.3

- old
+ new

@@ -27,9 +27,22 @@ end end end describe '#find_electoral_districts_by_postal_code' do + before :all do + { 'ElectionsCa' => 'elections_ca', + 'CBCCa' => 'cbc_ca', + 'NDPCa' => 'ndp_ca', + 'GreenPartyCa' => 'greenparty_ca', + }.each do |const,path| + %w(A1A1A1 K0A1K0 H0H0H0).each do |postal_code| + strategy = GovKit::CA::PostalCode::Strategy.const_get(const).new(postal_code) + FakeWeb.register_uri strategy.class.http_method, "#{strategy.class.base_uri}#{strategy.send(:path)}", :response => fixture_path(path, "#{postal_code}.response") + end + end + end + it 'should return the electoral districts within a postal code' do { 'A1A1A1' => [10007], 'K0A1K0' => [35012, 35025, 35040, 35052, 35063, 35064, 35087], }.each do |postal_code,electoral_districts| subject.find_electoral_districts_by_postal_code(postal_code).should == electoral_districts