govkit-ca 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d739c67d6d55b747e7a04bd5b6994fb6ff180319
4
- data.tar.gz: 166debfdb90619eb3bb57ee42eed52b6e96d8cc7
3
+ metadata.gz: 2ae05fc85b84b282bab633a2f50fe5aea6758511
4
+ data.tar.gz: 7f7cf3d90f90e54368342a5077427b48f08fd422
5
5
  SHA512:
6
- metadata.gz: f3e83609a5d3e78bdda0a712b7059b8eb37811fa93e3116431a14cec19a4a172a526f313ad9091c97a1961e07317e038780f2a9488c670f1d36de5bcb14126c2
7
- data.tar.gz: 1e09881041a35cd6c9cb0b6c20025b7dd92d119ad13fdb0fd1fcbf1505430b8a8eadc201eb42851033b9897b32a8c69e0f2e7ec3e0d9149110c043cf722e52fc
6
+ metadata.gz: b4f04a41569fce7b696d8865c9cac932e85d65428dec27862e9f09cbcfbdce1b74dedf209c178ecfc9b840a3bf1fdd1fba5039576ac71cf8a8cb157fffc0665d
7
+ data.tar.gz: b363b08cf0c3867180c033e761c7a891573cbbb384fe690909d2e9c2ddbf711d38bb5eeaea4a7cef7f5237ae90fef1c2a32f558a62515771d06f2123cf035253
@@ -3,3 +3,4 @@ rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
5
  - 2.0.0
6
+ - 2.1.0
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # GovKit-CA
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/govkit-ca.svg)](http://badge.fury.io/rb/govkit-ca)
3
4
  [![Build Status](https://secure.travis-ci.org/opennorth/govkit-ca.png)](http://travis-ci.org/opennorth/govkit-ca)
4
5
  [![Dependency Status](https://gemnasium.com/opennorth/govkit-ca.png)](https://gemnasium.com/opennorth/govkit-ca)
5
6
  [![Coverage Status](https://coveralls.io/repos/opennorth/govkit-ca/badge.png?branch=master)](https://coveralls.io/r/opennorth/govkit-ca)
@@ -13,15 +14,41 @@ GovKit-CA is a Ruby gem that provides easy access to Canadian civic information
13
14
 
14
15
  ## Represent API
15
16
 
16
- GovKit-CA provides a Represent API client.
17
+ GovKit-CA provides a [Represent API](http://represent.opennorth.ca/api/) client. First, create a client:
17
18
 
18
19
  ```ruby
19
20
  require 'govkit-ca'
21
+
20
22
  client = GovKit::CA::Represent.new
23
+ ```
24
+
25
+ Send a request to the [`/postcodes` endpoint](http://represent.opennorth.ca/api/#postcode):
26
+
27
+ ```ruby
21
28
  client.postcodes('A1A1A1')
29
+ ```
30
+
31
+ Send a request to the [`/representative-sets` endpoint](http://represent.opennorth.ca/api/#representativeset):
32
+
33
+ ```ruby
22
34
  client.representative_sets(limit: 0)
35
+ ```
36
+
37
+ Send a request to the [`/representatives` endpoint](http://represent.opennorth.ca/api/#representative):
38
+
39
+ ```ruby
23
40
  client.representatives(representative_set: 'toronto-city-council')
41
+ ```
42
+
43
+ Send a request to the [`/boundary-sets` endpoint](http://represent.opennorth.ca/api/#boundaryset):
44
+
45
+ ```ruby
24
46
  client.boundary_sets(limit: 0)
47
+ ```
48
+
49
+ Send a request to the [`/boundaries` endpoint](http://represent.opennorth.ca/api/#boundary):
50
+
51
+ ```ruby
25
52
  client.boundaries(boundary_set: 'toronto-wards')
26
53
  ```
27
54
 
@@ -29,22 +56,29 @@ Read the full documentation on [RubyDoc.info](http://rubydoc.info/gems/govkit-ca
29
56
 
30
57
  ## Postal code to electoral district lookup
31
58
 
32
- GovKit-CA provides an API for free postal code to electoral district lookups, using the following sources:
59
+ GovKit-CA provides an API for free postal code to electoral district lookups, using the sources:
33
60
 
34
61
  * [elections.ca](http://elections.ca/)
35
- * [cbc.ca](http://www.cbc.ca/)
36
- * [ndp.ca](http://www.ndp.ca/)
37
- * [digital-copyright.ca](http://www.digital-copyright.ca/)
38
- * [liberal.ca](http://www.liberal.ca/)
39
- * [greenparty.ca](http://www.greenparty.ca/)
40
62
  * [parl.gc.ca](http://www.parl.gc.ca/)
41
63
  * [conservative.ca](http://www.conservative.ca/)
64
+ * [greenparty.ca](http://www.greenparty.ca/)
65
+ * [liberal.ca](http://www.liberal.ca/)
66
+ * [ndp.ca](http://www.ndp.ca/)
67
+ * [cbc.ca](http://www.cbc.ca/)
68
+ * [digital-copyright.ca](http://www.digital-copyright.ca/)
69
+
70
+ These sources can be unstable or incorrect.
42
71
 
43
72
  ```ruby
44
73
  require 'govkit-ca'
45
74
 
75
+ # Register the sources to use.
76
+ GovKit::CA::PostalCode::StrategySet.register(GovKit::CA::PostalCode::Strategy::ElectionsCa)
77
+ GovKit::CA::PostalCode::StrategySet.register(GovKit::CA::PostalCode::Strategy::LiberalCa)
78
+ GovKit::CA::PostalCode::StrategySet.register(GovKit::CA::PostalCode::Strategy::NDPCa)
79
+
46
80
  GovKit::CA::PostalCode.find_electoral_districts_by_postal_code('A1A1A1') # [10007]
47
- GovKit::CA::PostalCode.find_electoral_districts_by_postal_code('K0A1K0') # [35012, 35025, 35040, 35052, 35063, 35064, 35087]
81
+ GovKit::CA::PostalCode.find_electoral_districts_by_postal_code('K0A1K0') # [35076]
48
82
  GovKit::CA::PostalCode.find_electoral_districts_by_postal_code('H0H0H0') # raises GovKit::CA::ResourceNotFound
49
83
 
50
84
  GovKit::CA::PostalCode.find_province_by_postal_code('A1A1A1') # "Newfoundland and Labrador"
@@ -15,4 +15,14 @@ module GovKit
15
15
  end
16
16
 
17
17
  require 'gov_kit-ca/postal_code'
18
+ require 'gov_kit-ca/postal_code/strategy_set'
19
+ require 'gov_kit-ca/postal_code/strategy/base'
20
+ require 'gov_kit-ca/postal_code/strategy/cbc_ca'
21
+ require 'gov_kit-ca/postal_code/strategy/conservative_ca'
22
+ require 'gov_kit-ca/postal_code/strategy/digital-copyright_ca'
23
+ require 'gov_kit-ca/postal_code/strategy/elections_ca'
24
+ require 'gov_kit-ca/postal_code/strategy/greenparty_ca'
25
+ require 'gov_kit-ca/postal_code/strategy/liberal_ca'
26
+ require 'gov_kit-ca/postal_code/strategy/ndp_ca'
27
+ require 'gov_kit-ca/postal_code/strategy/parl_gc_ca'
18
28
  require 'gov_kit-ca/represent'
@@ -76,29 +76,3 @@ module GovKit
76
76
  end
77
77
  end
78
78
  end
79
-
80
- require 'gov_kit-ca/postal_code/strategy_set'
81
- require 'gov_kit-ca/postal_code/strategy/base'
82
-
83
- # Only riding name and not implemented.
84
- # require 'gov_kit-ca/postal_code/strategy/parl_gc_ca'
85
-
86
- # Only one-to-one.
87
- require 'gov_kit-ca/postal_code/strategy/elections_ca'
88
-
89
- require 'gov_kit-ca/postal_code/strategy/ndp_ca'
90
-
91
- # Only one-to-one.
92
- require 'gov_kit-ca/postal_code/strategy/greenparty_ca'
93
-
94
- # Only riding name if not held by a Conservative MP.
95
- # require 'gov_kit-ca/postal_code/strategy/conservative_ca'
96
-
97
- # 2014-02-12: Occasionally renders HTML instead of redirect.
98
- # require 'gov_kit-ca/postal_code/strategy/liberal_ca'
99
-
100
- # 2014-02-12: Broken until next election.
101
- # require 'gov_kit-ca/postal_code/strategy/cbc_ca'
102
-
103
- # Too many or too few ridings.
104
- # require 'gov_kit-ca/postal_code/strategy/digital-copyright_ca'
@@ -24,8 +24,6 @@ module GovKit
24
24
  @@yml ||= YAML.load_file(File.expand_path('../../../../data/rid_to_edid.yml', __FILE__))
25
25
  end
26
26
  end
27
-
28
- StrategySet.register CBCCa
29
27
  end
30
28
  end
31
29
  end
@@ -21,8 +21,6 @@ module GovKit
21
21
  @images ||= Nokogiri::HTML(response.parsed_response, nil, 'utf-8').css('img')
22
22
  end
23
23
  end
24
-
25
- StrategySet.register ConservativeCa
26
24
  end
27
25
  end
28
26
  end
@@ -17,8 +17,6 @@ module GovKit
17
17
  !response.parsed_response.match /\b(invalid postal code|not found)\b/
18
18
  end
19
19
  end
20
-
21
- StrategySet.register DigitalCopyrightCa
22
20
  end
23
21
  end
24
22
  end
@@ -5,7 +5,7 @@ module GovKit
5
5
  class ElectionsCa < Base
6
6
  base_uri 'elections.ca'
7
7
  http_method :post
8
- path '/Scripts/vis/FindED'
8
+ path '/Scripts/vis/FindED?L=e&PAGEID=20'
9
9
  post_data 'CommonSearchTxt=<%= @postal_code %>'
10
10
 
11
11
  private
@@ -18,8 +18,6 @@ module GovKit
18
18
  !response.headers['location'][/EDNotFound|MultipleEDs/]
19
19
  end
20
20
  end
21
-
22
- StrategySet.register ElectionsCa
23
21
  end
24
22
  end
25
23
  end
@@ -4,8 +4,9 @@ module GovKit
4
4
  module Strategy
5
5
  class GreenPartyCa < Base
6
6
  base_uri 'www.greenparty.ca'
7
- http_method :head
8
- path '/search/green_geo/<%= @postal_code %>'
7
+ http_method :post
8
+ path '/en/party/find-your-riding'
9
+ post_data 'form_id=gpc_glue_riding_lookup_form&postal_code=<%= @postal_code %>'
9
10
 
10
11
  private
11
12
 
@@ -14,11 +15,9 @@ module GovKit
14
15
  end
15
16
 
16
17
  def valid?
17
- response.headers['location'] != 'http://www.greenparty.ca/find_your_riding'
18
+ response.headers['location'] != 'http://www.greenparty.ca/en/party/find-your-riding'
18
19
  end
19
20
  end
20
-
21
- StrategySet.register GreenPartyCa
22
21
  end
23
22
  end
24
23
  end
@@ -6,20 +6,18 @@ module GovKit
6
6
  follow_redirects true
7
7
  base_uri 'www.liberal.ca'
8
8
  http_method :get
9
- path '/riding/postal/<%= @postal_code %>/'
9
+ path '/ridings/<%= @postal_code %>/'
10
10
 
11
11
  private
12
12
 
13
13
  def electoral_districts!
14
- Nokogiri::HTML(response.parsed_response, nil, 'utf-8').css('img.RidingListImage').map{|img| img[:src][/\d{5}/]}
14
+ [response.parsed_response[%r{https://action.liberal.ca/en/donate/riding/(\d{5})}, 1]]
15
15
  end
16
16
 
17
17
  def valid?
18
- !response.parsed_response["Sorry we couldn't find your riding."]
18
+ !response.parsed_response["We couldn't find a riding for that postal code."]
19
19
  end
20
20
  end
21
-
22
- StrategySet.register LiberalCa
23
21
  end
24
22
  end
25
23
  end
@@ -17,8 +17,6 @@ module GovKit
17
17
  !response.parsed_response['No ridings or MPs match this search.']
18
18
  end
19
19
  end
20
-
21
- StrategySet.register NDPCa
22
20
  end
23
21
  end
24
22
  end
@@ -21,8 +21,6 @@ module GovKit
21
21
  @div ||= Nokogiri::HTML(response.parsed_response, nil, 'utf-8').at_css('#ctl00_cphContent_pnlWithMP')
22
22
  end
23
23
  end
24
-
25
- StrategySet.register ParlGcCa
26
24
  end
27
25
  end
28
26
  end
@@ -13,7 +13,7 @@ module GovKit
13
13
  # @param [Strategy::Base] strategy a strategy
14
14
  # @return [Array<Strategy::Base>] the strategy set
15
15
  def self.register(strategy)
16
- strategies << strategy
16
+ strategies << strategy unless strategies.include?(strategy)
17
17
  end
18
18
 
19
19
  # Runs through the strategies in order of registration. Returns the
@@ -1,5 +1,5 @@
1
1
  module GovKit
2
2
  module CA
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/cbc_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::CBCCa do
5
4
  describe '#electoral_districts', :broken => true do
6
5
  it 'should return the electoral districts within a postal code' do
7
6
  { 'G0C2Y0' => [24019],
8
- 'T5S2B9' => [48015, 48017],
7
+ 'T5S2B9' => [48015, 48017], # too many 48015
8
+ 'B0J2L0' => [12002, 12007, 12008],
9
9
  'K0A1K0' => [35025, 35052, 35063, 35064],
10
10
  }.each do |postal_code,electoral_districts|
11
11
  GovKit::CA::PostalCode::Strategy::CBCCa.new(postal_code).electoral_districts.should == electoral_districts
@@ -1,12 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/conservative_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
5
4
  describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
6
  { 'T1P1K1' => [48010],
8
7
  'K0A1K0' => [35025, 35052, 35063],
9
- # returns nothing for B0J2L0
10
8
  }.each do |postal_code,electoral_districts|
11
9
  GovKit::CA::PostalCode::Strategy::ConservativeCa.new(postal_code).electoral_districts.should == electoral_districts
12
10
  end
@@ -14,6 +12,8 @@ describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
14
12
 
15
13
  it 'should (unfortunately) return false if a postal code is held by another party' do
16
14
  GovKit::CA::PostalCode::Strategy::ConservativeCa.new('G0C2Y0').electoral_districts.should be_false
15
+ GovKit::CA::PostalCode::Strategy::ConservativeCa.new('T5S2B9').electoral_districts.should be_false
16
+ GovKit::CA::PostalCode::Strategy::ConservativeCa.new('B0J2L0').electoral_districts.should be_false
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code contains no electoral districts' do
@@ -1,13 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/digital-copyright_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa do
5
4
  describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
- { 'G0C2Y0' => [24019, 24039], # differs from all
8
- 'T5S2B9' => [48012, 48013, 48014, 48015, 48017, 48018], # differs from all
9
- 'K0A1K0' => [35025, 35052, 35063],
6
+ { 'G0C2Y0' => [24019, 24039], # too many 24019
7
+ 'T5S2B9' => [48012, 48013, 48014, 48015, 48017, 48018], # too many 48015
10
8
  'B0J2L0' => [12002, 12007, 12008],
9
+ 'K0A1K0' => [35025, 35052, 35063],
11
10
  }.each do |postal_code,electoral_districts|
12
11
  GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new(postal_code).electoral_districts.should == electoral_districts
13
12
  end
@@ -1,18 +1,18 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/elections_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
5
4
  describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
6
  { 'G0C2Y0' => [24019],
8
- # returns nothing for T5S2B9
7
+ 'T5S2B9' => [48015],
9
8
  }.each do |postal_code,electoral_districts|
10
9
  GovKit::CA::PostalCode::Strategy::ElectionsCa.new(postal_code).electoral_districts.should == electoral_districts
11
10
  end
12
11
  end
13
12
 
14
13
  it 'should (unfortunately) return false if a postal code contains multiple electoral districts' do
15
- GovKit::CA::PostalCode::Strategy::ElectionsCa.new('K0A1K0').electoral_districts.should be_false # B0J2L0
14
+ GovKit::CA::PostalCode::Strategy::ElectionsCa.new('B0J2L0').electoral_districts.should be_false
15
+ GovKit::CA::PostalCode::Strategy::ElectionsCa.new('K0A1K0').electoral_districts.should be_false
16
16
  end
17
17
 
18
18
  it 'should return false if a postal code contains no electoral districts' do
@@ -1,24 +1,18 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/greenparty_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::GreenPartyCa do
5
4
  describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
- { 'G0C2Y0' => [24019],
8
- 'T5S2B9' => [48015],
6
+ { 'G0C2Y0' => [24026],
7
+ 'T5S2B9' => [48031],
8
+ 'B0J2L0' => [12002], # too few
9
+ 'K0A1K0' => [35076], # too few
10
+ 'H0H0H0' => [24036], # wrong
9
11
  }.each do |postal_code,electoral_districts|
10
12
  GovKit::CA::PostalCode::Strategy::GreenPartyCa.new(postal_code).electoral_districts.should == electoral_districts
11
13
  end
12
14
  end
13
15
 
14
- it 'should (unfortunately) return false if a postal code contains multiple electoral districts' do
15
- GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('K0A1K0').electoral_districts.should be_false # B0J2L0
16
- end
17
-
18
- it 'should return false if a postal code contains no electoral districts' do
19
- GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('H0H0H0').electoral_districts.should be_false
20
- end
21
-
22
16
  it 'should return false if a postal code does not exist' do
23
17
  GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('X1B1B1').electoral_districts.should be_false
24
18
  end
@@ -1,13 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/liberal_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::LiberalCa do
5
- describe '#electoral_districts', :broken => true do
4
+ describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
- { 'G0C2Y0' => [24019],
8
- 'T5S2B9' => [48015],
9
- 'K0A1K0' => [35025, 35052, 35063],
10
- # returns nothing for B0J2L0
6
+ { 'G0C2Y0' => [24026],
7
+ 'T5S2B9' => [48031],
8
+ 'B0J2L0' => [12002], # too few
9
+ 'K0A1K0' => [35076], # too few
11
10
  }.each do |postal_code,electoral_districts|
12
11
  GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code).electoral_districts.should == electoral_districts
13
12
  end
@@ -1,13 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/ndp_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::NDPCa do
5
4
  describe '#electoral_districts' do
6
5
  it 'should return the electoral districts within a postal code' do
7
- { 'G0C2Y0' => [24019],
8
- 'T5S2B9' => [48015],
9
- 'K0A1K0' => [35012, 35025, 35040, 35052],
10
- 'B0J2L0' => [12002, 12006, 12009, 12011],
6
+ { 'G0C2Y0' => [24026],
7
+ 'T5S2B9' => [48020, 48031], # too many 48031
8
+ 'B0J2L0' => [12002], # too few
9
+ 'K0A1K0' => [35031, 35076, 35088],
11
10
  }.each do |postal_code,electoral_districts|
12
11
  GovKit::CA::PostalCode::Strategy::NDPCa.new(postal_code).electoral_districts.should == electoral_districts
13
12
  end
@@ -1,5 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'gov_kit-ca/postal_code/strategy/parl_gc_ca'
3
2
 
4
3
  describe GovKit::CA::PostalCode::Strategy::ParlGcCa do
5
4
  describe '#electoral_districts' do
@@ -1,6 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe GovKit::CA::PostalCode do
4
+ before :all do
5
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::ElectionsCa
6
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::LiberalCa
7
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::NDPCa
8
+ end
9
+
4
10
  describe '#valid?' do
5
11
  it 'should return false if the postal code is not properly formatted' do
6
12
  [ 'A1A1A', # too short
@@ -30,7 +36,7 @@ describe GovKit::CA::PostalCode do
30
36
  describe '#find_electoral_districts_by_postal_code' do
31
37
  it 'should return the electoral districts within a postal code' do
32
38
  { 'A1A1A1' => [10007],
33
- 'K0A1K0' => [35012, 35025, 35040, 35052],
39
+ 'K0A1K0' => [35076],
34
40
  }.each do |postal_code,electoral_districts|
35
41
  subject.find_electoral_districts_by_postal_code(postal_code).should == electoral_districts
36
42
  end
@@ -85,17 +85,17 @@ describe GovKit::CA::Represent do
85
85
  it 'should accept an array of boundary sets' do
86
86
  response = api.postcodes('A1A1A1', :sets => ['federal-electoral-districts', 'census-subdivisions'])
87
87
  response.should be_a(Hash)
88
- response['boundaries_centroid'].should have(2).items
88
+ (response['boundaries_centroid'] + response['boundaries_concordance']).should have(2).items
89
89
  end
90
90
 
91
91
  it 'should accept a comma-separated list of boundary sets' do
92
92
  response = api.postcodes('A1A1A1', :sets => 'federal-electoral-districts,census-subdivisions')
93
93
  response.should be_a(Hash)
94
- response['boundaries_centroid'].should have(2).items
94
+ (response['boundaries_centroid'] + response['boundaries_concordance']).should have(2).items
95
95
  end
96
96
 
97
97
  it 'should raise an error if the postal code does not exist' do
98
- expect{api.postcodes('foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/postcodes/foo/?")
98
+ expect{api.postcodes('foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/postcodes/FOO/?")
99
99
  end
100
100
  end
101
101
 
@@ -5,29 +5,37 @@ describe GovKit::CA::PostalCode::StrategySet do
5
5
  Class.new
6
6
  end
7
7
 
8
- describe '#strategies' do
9
- it 'should return the strategies' do
10
- GovKit::CA::PostalCode::StrategySet.strategies[0..4].should == [
11
- GovKit::CA::PostalCode::Strategy::ElectionsCa,
12
- GovKit::CA::PostalCode::Strategy::NDPCa,
13
- # GovKit::CA::PostalCode::Strategy::LiberalCa,
14
- GovKit::CA::PostalCode::Strategy::GreenPartyCa,
15
- GovKit::CA::PostalCode::Strategy::CBCCa,
16
- GovKit::CA::PostalCode::Strategy::ConservativeCa,
17
- ]
8
+ context 'with strategy set' do
9
+ before :all do
10
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::ElectionsCa
11
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::LiberalCa
12
+ GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::NDPCa
18
13
  end
19
- end
20
14
 
21
- describe '#register' do
22
- it 'should append a strategy' do
23
- GovKit::CA::PostalCode::StrategySet.register(strategy)
24
- GovKit::CA::PostalCode::StrategySet.strategies.last.should == strategy
15
+ describe '#strategies' do
16
+ it 'should return the strategies' do
17
+ GovKit::CA::PostalCode::StrategySet.strategies[0..4].should == [
18
+ GovKit::CA::PostalCode::Strategy::ElectionsCa,
19
+ GovKit::CA::PostalCode::Strategy::LiberalCa,
20
+ GovKit::CA::PostalCode::Strategy::NDPCa,
21
+ # GovKit::CA::PostalCode::Strategy::GreenPartyCa,
22
+ # GovKit::CA::PostalCode::Strategy::CBCCa,
23
+ # GovKit::CA::PostalCode::Strategy::ConservativeCa,
24
+ ]
25
+ end
26
+ end
27
+
28
+ describe '#register' do
29
+ it 'should append a strategy' do
30
+ GovKit::CA::PostalCode::StrategySet.register(strategy)
31
+ GovKit::CA::PostalCode::StrategySet.strategies.last.should == strategy
32
+ end
25
33
  end
26
- end
27
34
 
28
- describe '#run' do
29
- it 'should run the strategies' do
30
- GovKit::CA::PostalCode::StrategySet.run('A1A1A1').should == [10007]
35
+ describe '#run' do
36
+ it 'should run the strategies' do
37
+ GovKit::CA::PostalCode::StrategySet.run('A1A1A1').should == [10007]
38
+ end
31
39
  end
32
40
  end
33
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govkit-ca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday