govkit-ca 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ae05fc85b84b282bab633a2f50fe5aea6758511
4
- data.tar.gz: 7f7cf3d90f90e54368342a5077427b48f08fd422
3
+ metadata.gz: 60277f47ef35ddd41b20164989eb02e673e0b6ff
4
+ data.tar.gz: 5b1c0312a70afa33193bc0a676959d18755e5c02
5
5
  SHA512:
6
- metadata.gz: b4f04a41569fce7b696d8865c9cac932e85d65428dec27862e9f09cbcfbdce1b74dedf209c178ecfc9b840a3bf1fdd1fba5039576ac71cf8a8cb157fffc0665d
7
- data.tar.gz: b363b08cf0c3867180c033e761c7a891573cbbb384fe690909d2e9c2ddbf711d38bb5eeaea4a7cef7f5237ae90fef1c2a32f558a62515771d06f2123cf035253
6
+ metadata.gz: 8013b9e8b88f57696fca95e51009b4e5a787170eb7873b2db2c105213f9a8729433ddd5204063f79aa832a58c7a84d0194ae5f424280129a32a81604aef656ce
7
+ data.tar.gz: cb0376eba458d2778c83a9a1040838068ffb188b878879c7c495e8e6d33c41919c76e992f26b054bdddbe25d7798063ef2404ee2a188958953c5eaf458136b73
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.0
6
+ - 2.2.0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in govkit-ca.gemspec
3
+ # Specify your gem's dependencies in the gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # GovKit-CA
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/govkit-ca.svg)](http://badge.fury.io/rb/govkit-ca)
4
- [![Build Status](https://secure.travis-ci.org/opennorth/govkit-ca.png)](http://travis-ci.org/opennorth/govkit-ca)
3
+ [![Gem Version](https://badge.fury.io/rb/govkit-ca.svg)](https://badge.fury.io/rb/govkit-ca)
4
+ [![Build Status](https://secure.travis-ci.org/opennorth/govkit-ca.png)](https://travis-ci.org/opennorth/govkit-ca)
5
5
  [![Dependency Status](https://gemnasium.com/opennorth/govkit-ca.png)](https://gemnasium.com/opennorth/govkit-ca)
6
6
  [![Coverage Status](https://coveralls.io/repos/opennorth/govkit-ca/badge.png?branch=master)](https://coveralls.io/r/opennorth/govkit-ca)
7
7
  [![Code Climate](https://codeclimate.com/github/opennorth/govkit-ca.png)](https://codeclimate.com/github/opennorth/govkit-ca)
@@ -14,7 +14,7 @@ GovKit-CA is a Ruby gem that provides easy access to Canadian civic information
14
14
 
15
15
  ## Represent API
16
16
 
17
- GovKit-CA provides a [Represent API](http://represent.opennorth.ca/api/) client. First, create a client:
17
+ GovKit-CA provides a [Represent API](https://represent.opennorth.ca/api/) client. First, create a client:
18
18
 
19
19
  ```ruby
20
20
  require 'govkit-ca'
@@ -22,31 +22,31 @@ require 'govkit-ca'
22
22
  client = GovKit::CA::Represent.new
23
23
  ```
24
24
 
25
- Send a request to the [`/postcodes` endpoint](http://represent.opennorth.ca/api/#postcode):
25
+ Send a request to the [`/postcodes` endpoint](https://represent.opennorth.ca/api/#postcode):
26
26
 
27
27
  ```ruby
28
28
  client.postcodes('A1A1A1')
29
29
  ```
30
30
 
31
- Send a request to the [`/representative-sets` endpoint](http://represent.opennorth.ca/api/#representativeset):
31
+ Send a request to the [`/representative-sets` endpoint](https://represent.opennorth.ca/api/#representativeset):
32
32
 
33
33
  ```ruby
34
34
  client.representative_sets(limit: 0)
35
35
  ```
36
36
 
37
- Send a request to the [`/representatives` endpoint](http://represent.opennorth.ca/api/#representative):
37
+ Send a request to the [`/representatives` endpoint](https://represent.opennorth.ca/api/#representative):
38
38
 
39
39
  ```ruby
40
40
  client.representatives(representative_set: 'toronto-city-council')
41
41
  ```
42
42
 
43
- Send a request to the [`/boundary-sets` endpoint](http://represent.opennorth.ca/api/#boundaryset):
43
+ Send a request to the [`/boundary-sets` endpoint](https://represent.opennorth.ca/api/#boundaryset):
44
44
 
45
45
  ```ruby
46
46
  client.boundary_sets(limit: 0)
47
47
  ```
48
48
 
49
- Send a request to the [`/boundaries` endpoint](http://represent.opennorth.ca/api/#boundary):
49
+ Send a request to the [`/boundaries` endpoint](https://represent.opennorth.ca/api/#boundary):
50
50
 
51
51
  ```ruby
52
52
  client.boundaries(boundary_set: 'toronto-wards')
@@ -62,7 +62,7 @@ GovKit-CA provides an API for free postal code to electoral district lookups, us
62
62
  * [parl.gc.ca](http://www.parl.gc.ca/)
63
63
  * [conservative.ca](http://www.conservative.ca/)
64
64
  * [greenparty.ca](http://www.greenparty.ca/)
65
- * [liberal.ca](http://www.liberal.ca/)
65
+ * [liberal.ca](https://www.liberal.ca/)
66
66
  * [ndp.ca](http://www.ndp.ca/)
67
67
  * [cbc.ca](http://www.cbc.ca/)
68
68
  * [digital-copyright.ca](http://www.digital-copyright.ca/)
@@ -94,8 +94,4 @@ GovKit-CA will raise `GovKit::CA::ResourceNotFound` if the electoral districts w
94
94
 
95
95
  GovKit-CA interoperates with the [Participatory Politics Foundation](http://www.participatorypolitics.org/)'s [GovKit](https://github.com/opengovernment/govkit). GovKit-CA is not affiliated with the Participatory Politics Foundation or GovKit.
96
96
 
97
- ## Bugs? Questions?
98
-
99
- This gem's main repository is on GitHub: [http://github.com/opennorth/govkit-ca](http://github.com/opennorth/govkit-ca), where your contributions, forks, bug reports, feature requests, and feedback are greatly welcomed.
100
-
101
97
  Copyright (c) 2011 Open North Inc., released under the MIT license
@@ -7,11 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Open North"]
9
9
  s.email = ["info@opennorth.ca"]
10
- s.homepage = "http://github.com/opennorth/govkit-ca"
10
+ s.homepage = "https://github.com/opennorth/govkit-ca"
11
11
  s.summary = %q{Easy access to Canadian civic data around the web}
12
12
  s.description = %q{GovKit-CA lets you quickly get encapsulated Ruby objects for Canadian civic data.}
13
-
14
- s.rubyforge_project = "govkit-ca"
15
13
  s.license = 'MIT'
16
14
 
17
15
  s.files = `git ls-files`.split("\n")
@@ -22,9 +20,10 @@ Gem::Specification.new do |s|
22
20
  s.add_runtime_dependency('faraday')
23
21
  s.add_runtime_dependency('httparty', '~> 0.10.0')
24
22
  s.add_runtime_dependency('nokogiri', '~> 1.6.0')
25
- s.add_development_dependency('json')
26
- s.add_development_dependency('rspec', '~> 2.6.0')
27
- s.add_development_dependency('rake', '~> 10.1.0')
23
+
28
24
  s.add_development_dependency('coveralls')
25
+ s.add_development_dependency('json', '~> 1.8') # to silence coveralls warning
26
+ s.add_development_dependency('rake')
27
+ s.add_development_dependency('rspec', '~> 3.1')
29
28
  s.add_development_dependency('mime-types', '~> 1.16')
30
29
  end
@@ -1,11 +1,11 @@
1
1
  module GovKit
2
2
  module CA
3
3
  # A collection of postal code helpers.
4
- # @see http://en.wikipedia.org/wiki/Postal_codes_in_Canada Postal codes in Canada
4
+ # @see https://en.wikipedia.org/wiki/Postal_codes_in_Canada Postal codes in Canada
5
5
  module PostalCode
6
6
  # @param [String] postal_code a postal code
7
7
  # @return [Boolean] whether the postal code is properly formatted
8
- # @see http://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes Possible postal codes
8
+ # @see https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes Possible postal codes
9
9
  def self.valid?(postal_code)
10
10
  !!postal_code.match(/\A[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ][0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]\z/)
11
11
  end
@@ -32,7 +32,7 @@ module GovKit
32
32
  # @param [String] postal_code a postal code
33
33
  # @return [String] the province that the postal code belongs to
34
34
  # @raise [ResourceNotFound] if the province cannot be determined
35
- # @see http://en.wikipedia.org/wiki/List_of_postal_codes_in_Canada List of postal codes in Canada
35
+ # @see https://en.wikipedia.org/wiki/List_of_postal_codes_in_Canada List of postal codes in Canada
36
36
  def self.find_province_by_postal_code(postal_code)
37
37
  case format_postal_code(postal_code)
38
38
  when /\AA/
@@ -55,7 +55,7 @@ module GovKit
55
55
  'Alberta'
56
56
  when /\AV/
57
57
  'British Columbia'
58
- # http://en.wikipedia.org/wiki/List_of_X_postal_codes_of_Canada
58
+ # https://en.wikipedia.org/wiki/List_of_X_postal_codes_of_Canada
59
59
  when /\AX0[ABC]/
60
60
  'Nunavut'
61
61
  when /\AX0[EG]/, /\AX1A/
@@ -21,7 +21,7 @@ module GovKit
21
21
  # canonical electoral district ID.
22
22
  # @return [Hash] a map of cbc.ca riding ID to electoral district ID
23
23
  def self.rid_to_edid
24
- @@yml ||= YAML.load_file(File.expand_path('../../../../data/rid_to_edid.yml', __FILE__))
24
+ @@yml ||= YAML.load_file(File.expand_path('../../../../rid_to_edid.yml', __FILE__))
25
25
  end
26
26
  end
27
27
  end
@@ -5,17 +5,17 @@ module GovKit
5
5
  class ElectionsCa < Base
6
6
  base_uri 'elections.ca'
7
7
  http_method :post
8
- path '/Scripts/vis/FindED?L=e&PAGEID=20'
9
- post_data 'CommonSearchTxt=<%= @postal_code %>'
8
+ path '/Scripts/vis/FindED?L=e&QID=-1&PAGEID=20'
9
+ post_data 'CommonSearchTxt=<%= @postal_code %>&CivicSearchTxt=1'
10
10
 
11
11
  private
12
12
 
13
13
  def electoral_districts!
14
- [ response.headers['location'][/\bED=(\d{5})&/, 1] ]
14
+ [response.headers['location'][/\bED=(\d{5})&/, 1]]
15
15
  end
16
16
 
17
17
  def valid?
18
- !response.headers['location'][/EDNotFound|MultipleEDs/]
18
+ !response.headers['location']['/ShowStreets?']
19
19
  end
20
20
  end
21
21
  end
@@ -11,7 +11,7 @@ module GovKit
11
11
  private
12
12
 
13
13
  def electoral_districts!
14
- [ response.headers['location'][/\d+\z/] ]
14
+ [response.headers['location'][/\d+\z/]]
15
15
  end
16
16
 
17
17
  def valid?
@@ -1,7 +1,7 @@
1
1
  module GovKit
2
2
  module CA
3
3
  # A Ruby wrapper for the Represent API.
4
- # @see http://represent.opennorth.ca/api/
4
+ # @see https://represent.opennorth.ca/api/
5
5
  class Represent
6
6
  # @param [Faraday::Connection] connection a Faraday connection
7
7
  def initialize(connection = nil)
@@ -14,7 +14,7 @@ module GovKit
14
14
  # @option opts [String] :boundary_set a boundary set
15
15
  # @option opts [Integer] :limit
16
16
  # @option opts [Integer] :offset
17
- # @see http://represent.opennorth.ca/api/#boundaryset
17
+ # @see https://represent.opennorth.ca/api/#boundaryset
18
18
  def boundary_sets(opts = {})
19
19
  request(['boundary-sets', opts.delete(:boundary_set)], opts)
20
20
  end
@@ -31,7 +31,7 @@ module GovKit
31
31
  # @option opts [String] :intersects a boundary
32
32
  # @option opts [Integer] :limit
33
33
  # @option opts [Integer] :offset
34
- # @see http://represent.opennorth.ca/api/#boundary
34
+ # @see https://represent.opennorth.ca/api/#boundary
35
35
  def boundaries(opts = {})
36
36
  if Array === opts[:sets]
37
37
  opts[:sets] = opts[:sets].join(',')
@@ -54,7 +54,7 @@ module GovKit
54
54
  # @option opts [Array<String>,String] :sets comma-separated list of boundary sets
55
55
  # @option opts [Integer] :limit
56
56
  # @option opts [Integer] :offset
57
- # @see http://represent.opennorth.ca/api/#postcode
57
+ # @see https://represent.opennorth.ca/api/#postcode
58
58
  def postcodes(postcode, opts = {})
59
59
  if Array === opts[:sets]
60
60
  opts[:sets] = opts[:sets].join(',')
@@ -68,7 +68,7 @@ module GovKit
68
68
  # @option opts [String] :representative_set a representative set
69
69
  # @option opts [Integer] :limit
70
70
  # @option opts [Integer] :offset
71
- # @see http://represent.opennorth.ca/api/#representativeset
71
+ # @see https://represent.opennorth.ca/api/#representativeset
72
72
  def representative_sets(opts = {})
73
73
  request ['representative-sets', opts.delete(:representative_set)], opts
74
74
  end
@@ -81,7 +81,7 @@ module GovKit
81
81
  # @option opts [Array<Strong>,String] :districts a comma-separated list of boundaries
82
82
  # @option opts [Integer] :limit
83
83
  # @option opts [Integer] :offset
84
- # @see http://represent.opennorth.ca/api/#representative
84
+ # @see https://represent.opennorth.ca/api/#representative
85
85
  def representatives(opts = {})
86
86
  if Array === opts[:point]
87
87
  opts[:point] = opts[:point].join(',')
@@ -96,7 +96,7 @@ module GovKit
96
96
 
97
97
  def request(parts, opts)
98
98
  begin
99
- url = "http://represent.opennorth.ca/#{parts.compact.join('/')}/"
99
+ url = "https://represent.opennorth.ca/#{parts.compact.join('/')}/"
100
100
  response = @client.get(url, opts)
101
101
  case response.status
102
102
  when 200
@@ -1,5 +1,5 @@
1
1
  module GovKit
2
2
  module CA
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::CBCCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::CBCCa do
4
4
  describe '#electoral_districts', :broken => true do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24019],
@@ -8,16 +8,16 @@ describe GovKit::CA::PostalCode::Strategy::CBCCa do
8
8
  'B0J2L0' => [12002, 12007, 12008],
9
9
  'K0A1K0' => [35025, 35052, 35063, 35064],
10
10
  }.each do |postal_code,electoral_districts|
11
- GovKit::CA::PostalCode::Strategy::CBCCa.new(postal_code).electoral_districts.should == electoral_districts
11
+ expect(GovKit::CA::PostalCode::Strategy::CBCCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
12
  end
13
13
  end
14
14
 
15
15
  it 'should return false if a postal code contains no electoral districts' do
16
- GovKit::CA::PostalCode::Strategy::CBCCa.new('H0H0H0').electoral_districts.should be_false
16
+ expect(GovKit::CA::PostalCode::Strategy::CBCCa.new('H0H0H0').electoral_districts).to eq(false)
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code does not exist' do
20
- GovKit::CA::PostalCode::Strategy::CBCCa.new('X1B1B1').electoral_districts.should be_false
20
+ expect(GovKit::CA::PostalCode::Strategy::CBCCa.new('X1B1B1').electoral_districts).to eq(false)
21
21
  end
22
22
  end
23
23
  end
@@ -1,27 +1,27 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::ConservativeCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'T1P1K1' => [48010],
7
7
  'K0A1K0' => [35025, 35052, 35063],
8
8
  }.each do |postal_code,electoral_districts|
9
- GovKit::CA::PostalCode::Strategy::ConservativeCa.new(postal_code).electoral_districts.should == electoral_districts
9
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new(postal_code).electoral_districts).to eq(electoral_districts)
10
10
  end
11
11
  end
12
12
 
13
13
  it 'should (unfortunately) return false if a postal code is held by another party' do
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
14
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('G0C2Y0').electoral_districts).to eq(false)
15
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('T5S2B9').electoral_districts).to eq(false)
16
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('B0J2L0').electoral_districts).to eq(false)
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code contains no electoral districts' do
20
- GovKit::CA::PostalCode::Strategy::ConservativeCa.new('H0H0H0').electoral_districts.should be_false
20
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('H0H0H0').electoral_districts).to eq(false)
21
21
  end
22
22
 
23
23
  it 'should return false if a postal code does not exist' do
24
- GovKit::CA::PostalCode::Strategy::ConservativeCa.new('X1B1B1').electoral_districts.should be_false
24
+ expect(GovKit::CA::PostalCode::Strategy::ConservativeCa.new('X1B1B1').electoral_districts).to eq(false)
25
25
  end
26
26
  end
27
27
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24019, 24039], # too many 24019
@@ -8,16 +8,16 @@ describe GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa do
8
8
  'B0J2L0' => [12002, 12007, 12008],
9
9
  'K0A1K0' => [35025, 35052, 35063],
10
10
  }.each do |postal_code,electoral_districts|
11
- GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new(postal_code).electoral_districts.should == electoral_districts
11
+ expect(GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
12
  end
13
13
  end
14
14
 
15
15
  it 'should return false if a postal code contains no electoral districts' do
16
- GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new('H0H0H0').electoral_districts.should be_false
16
+ expect(GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new('H0H0H0').electoral_districts).to eq(false)
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code does not exist' do
20
- GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new('X1B1B1').electoral_districts.should be_false
20
+ expect(GovKit::CA::PostalCode::Strategy::DigitalCopyrightCa.new('X1B1B1').electoral_districts).to eq(false)
21
21
  end
22
22
  end
23
23
  end
@@ -1,26 +1,26 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::ElectionsCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24019],
7
7
  'T5S2B9' => [48015],
8
8
  }.each do |postal_code,electoral_districts|
9
- GovKit::CA::PostalCode::Strategy::ElectionsCa.new(postal_code).electoral_districts.should == electoral_districts
9
+ expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new(postal_code).electoral_districts).to eq(electoral_districts)
10
10
  end
11
11
  end
12
12
 
13
13
  it 'should (unfortunately) return false if a postal code contains multiple electoral districts' do
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
14
+ expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new('B0J2L0').electoral_districts).to eq(false)
15
+ expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new('K0A1K0').electoral_districts).to eq(false)
16
16
  end
17
17
 
18
18
  it 'should return false if a postal code contains no electoral districts' do
19
- GovKit::CA::PostalCode::Strategy::ElectionsCa.new('H0H0H0').electoral_districts.should be_false
19
+ expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new('H0H0H0').electoral_districts).to eq(false)
20
20
  end
21
21
 
22
22
  it 'should return false if a postal code does not exist' do
23
- GovKit::CA::PostalCode::Strategy::ElectionsCa.new('X1B1B1').electoral_districts.should be_false
23
+ expect(GovKit::CA::PostalCode::Strategy::ElectionsCa.new('X1B1B1').electoral_districts).to eq(false)
24
24
  end
25
25
  end
26
26
  end
@@ -1,20 +1,26 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::GreenPartyCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::GreenPartyCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24026],
7
7
  'T5S2B9' => [48031],
8
- 'B0J2L0' => [12002], # too few
9
- 'K0A1K0' => [35076], # too few
10
- 'H0H0H0' => [24036], # wrong
11
8
  }.each do |postal_code,electoral_districts|
12
- GovKit::CA::PostalCode::Strategy::GreenPartyCa.new(postal_code).electoral_districts.should == electoral_districts
9
+ expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new(postal_code).electoral_districts).to eq(electoral_districts)
13
10
  end
14
11
  end
15
12
 
13
+ it 'should (unfortunately) return false if a postal code contains multiple electoral districts' do
14
+ expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('B0J2L0').electoral_districts).to eq(false)
15
+ expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('K0A1K0').electoral_districts).to eq(false)
16
+ end
17
+
18
+ it 'should return false if a postal code contains no electoral districts' do
19
+ expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('H0H0H0').electoral_districts).to eq(false)
20
+ end
21
+
16
22
  it 'should return false if a postal code does not exist' do
17
- GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('X1B1B1').electoral_districts.should be_false
23
+ expect(GovKit::CA::PostalCode::Strategy::GreenPartyCa.new('X1B1B1').electoral_districts).to eq(false)
18
24
  end
19
25
  end
20
26
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::LiberalCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::LiberalCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24026],
@@ -8,16 +8,16 @@ describe GovKit::CA::PostalCode::Strategy::LiberalCa do
8
8
  'B0J2L0' => [12002], # too few
9
9
  'K0A1K0' => [35076], # too few
10
10
  }.each do |postal_code,electoral_districts|
11
- GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code).electoral_districts.should == electoral_districts
11
+ expect(GovKit::CA::PostalCode::Strategy::LiberalCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
12
  end
13
13
  end
14
14
 
15
15
  it 'should return false if a postal code contains no electoral districts' do
16
- GovKit::CA::PostalCode::Strategy::LiberalCa.new('H0H0H0').electoral_districts.should be_false
16
+ expect(GovKit::CA::PostalCode::Strategy::LiberalCa.new('H0H0H0').electoral_districts).to eq(false)
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code does not exist' do
20
- GovKit::CA::PostalCode::Strategy::LiberalCa.new('X1B1B1').electoral_districts.should be_false
20
+ expect(GovKit::CA::PostalCode::Strategy::LiberalCa.new('X1B1B1').electoral_districts).to eq(false)
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::NDPCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::NDPCa do
4
4
  describe '#electoral_districts' do
5
5
  it 'should return the electoral districts within a postal code' do
6
6
  { 'G0C2Y0' => [24026],
@@ -8,16 +8,16 @@ describe GovKit::CA::PostalCode::Strategy::NDPCa do
8
8
  'B0J2L0' => [12002], # too few
9
9
  'K0A1K0' => [35031, 35076, 35088],
10
10
  }.each do |postal_code,electoral_districts|
11
- GovKit::CA::PostalCode::Strategy::NDPCa.new(postal_code).electoral_districts.should == electoral_districts
11
+ expect(GovKit::CA::PostalCode::Strategy::NDPCa.new(postal_code).electoral_districts).to eq(electoral_districts)
12
12
  end
13
13
  end
14
14
 
15
15
  it 'should return false if a postal code contains no electoral districts' do
16
- GovKit::CA::PostalCode::Strategy::NDPCa.new('H0H0H0').electoral_districts.should be_false
16
+ expect(GovKit::CA::PostalCode::Strategy::NDPCa.new('H0H0H0').electoral_districts).to eq(false)
17
17
  end
18
18
 
19
19
  it 'should return false if a postal code does not exist' do
20
- GovKit::CA::PostalCode::Strategy::NDPCa.new('X1B1B1').electoral_districts.should be_false
20
+ expect(GovKit::CA::PostalCode::Strategy::NDPCa.new('X1B1B1').electoral_districts).to eq(false)
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::Strategy::ParlGcCa do
3
+ RSpec.describe GovKit::CA::PostalCode::Strategy::ParlGcCa do
4
4
  describe '#electoral_districts' do
5
5
  pending
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode do
3
+ RSpec.describe GovKit::CA::PostalCode do
4
4
  before :all do
5
5
  GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::ElectionsCa
6
6
  GovKit::CA::PostalCode::StrategySet.register GovKit::CA::PostalCode::Strategy::LiberalCa
@@ -19,7 +19,7 @@ describe GovKit::CA::PostalCode do
19
19
  'Q1Q1Q1', # Q as letter
20
20
  'a1a1a1', # lowercase
21
21
  ].each do |postal_code|
22
- subject.valid?(postal_code).should be_false
22
+ expect(subject.valid?(postal_code)).to eq(false)
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ describe GovKit::CA::PostalCode do
28
28
  'H0H0H0', # doesn't exist
29
29
  'A1A1A1', # does exist
30
30
  ].each do |postal_code|
31
- subject.valid?(postal_code).should be_true
31
+ expect(subject.valid?(postal_code)).to eq(true)
32
32
  end
33
33
  end
34
34
  end
@@ -38,16 +38,16 @@ describe GovKit::CA::PostalCode do
38
38
  { 'A1A1A1' => [10007],
39
39
  'K0A1K0' => [35076],
40
40
  }.each do |postal_code,electoral_districts|
41
- subject.find_electoral_districts_by_postal_code(postal_code).should == electoral_districts
41
+ expect(subject.find_electoral_districts_by_postal_code(postal_code)).to eq(electoral_districts)
42
42
  end
43
43
  end
44
44
 
45
45
  it 'should raise an error if the postal code cannot be determined' do
46
- lambda{subject.find_electoral_districts_by_postal_code('H0H0H0')}.should raise_error(GovKit::CA::ResourceNotFound)
46
+ expect(lambda{subject.find_electoral_districts_by_postal_code('H0H0H0')}).to raise_error(GovKit::CA::ResourceNotFound)
47
47
  end
48
48
 
49
49
  it 'should raise an error if the postal code is invalid' do
50
- lambda{subject.find_electoral_districts_by_postal_code('AAAAAA')}.should raise_error(GovKit::CA::InvalidRequest)
50
+ expect(lambda{subject.find_electoral_districts_by_postal_code('AAAAAA')}).to raise_error(GovKit::CA::InvalidRequest)
51
51
  end
52
52
  end
53
53
 
@@ -76,19 +76,19 @@ describe GovKit::CA::PostalCode do
76
76
  'X0G' => 'Northwest Territories',
77
77
  'X1A' => 'Northwest Territories',
78
78
  'Y' => 'Yukon',
79
- }.each do |postal_code, province|
80
- subject.find_province_by_postal_code(postal_code).should == province
79
+ }.each do |postal_code,province|
80
+ expect(subject.find_province_by_postal_code(postal_code)).to eq(province)
81
81
  end
82
82
  end
83
83
 
84
84
  it 'should raise an error if the province cannot be determined' do
85
- lambda{subject.find_province_by_postal_code('X1B1B1')}.should raise_error(GovKit::CA::ResourceNotFound)
85
+ expect(lambda{subject.find_province_by_postal_code('X1B1B1')}).to raise_error(GovKit::CA::ResourceNotFound)
86
86
  end
87
87
  end
88
88
 
89
89
  describe '#format_postal_code' do
90
90
  it 'should format a postal code' do
91
- subject.format_postal_code("+a1a 1a1\n").should == 'A1A1A1'
91
+ expect(subject.format_postal_code("+a1a 1a1\n")).to eq('A1A1A1')
92
92
  end
93
93
  end
94
94
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::Represent do
3
+ RSpec.describe GovKit::CA::Represent do
4
4
  describe '#boundary_sets' do
5
5
  let :api do
6
6
  GovKit::CA::Represent.new
@@ -16,27 +16,27 @@ describe GovKit::CA::Represent do
16
16
 
17
17
  it 'should return boundary sets' do
18
18
  response = api.boundary_sets
19
- response.should be_a(Hash)
20
- response.should have_key('objects')
21
- response.should have_key('meta')
19
+ expect(response).to be_a(Hash)
20
+ expect(response).to have_key('objects')
21
+ expect(response).to have_key('meta')
22
22
  end
23
23
 
24
24
  it 'should return a boundary set' do
25
25
  response = api.boundary_sets(:boundary_set => 'federal-electoral-districts')
26
- response.should be_a(Hash)
27
- response.should have_key('related')
26
+ expect(response).to be_a(Hash)
27
+ expect(response).to have_key('related')
28
28
  end
29
29
 
30
30
  it 'should raise an error if the boundary set does not exist' do
31
- expect{api.boundary_sets(:boundary_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/boundary-sets/foo/?")
31
+ expect{api.boundary_sets(:boundary_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 https://represent.opennorth.ca/boundary-sets/foo/?")
32
32
  end
33
33
 
34
34
  it 'should raise an error if the limit is invalid' do
35
- expect{api.boundary_sets(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/boundary-sets/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
35
+ expect{api.boundary_sets(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/boundary-sets/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
36
36
  end
37
37
 
38
38
  it 'should raise an error if the offset is invalid' do
39
- expect{api.boundary_sets(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/boundary-sets/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
39
+ expect{api.boundary_sets(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/boundary-sets/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
40
40
  end
41
41
  end
42
42
 
@@ -47,27 +47,27 @@ describe GovKit::CA::Represent do
47
47
 
48
48
  it 'should return representative sets' do
49
49
  response = api.representative_sets
50
- response.should be_a(Hash)
51
- response.should have_key('objects')
52
- response.should have_key('meta')
50
+ expect(response).to be_a(Hash)
51
+ expect(response).to have_key('objects')
52
+ expect(response).to have_key('meta')
53
53
  end
54
54
 
55
55
  it 'should return a representative set' do
56
56
  response = api.representative_sets(:representative_set => 'house-of-commons')
57
- response.should be_a(Hash)
58
- response.should have_key('related')
57
+ expect(response).to be_a(Hash)
58
+ expect(response).to have_key('related')
59
59
  end
60
60
 
61
61
  it 'should raise an error if the representative set does not exist' do
62
- expect{api.representative_sets(:representative_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/representative-sets/foo/?")
62
+ expect{api.representative_sets(:representative_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 https://represent.opennorth.ca/representative-sets/foo/?")
63
63
  end
64
64
 
65
65
  it 'should raise an error if the limit is invalid' do
66
- expect{api.representative_sets(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/representative-sets/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
66
+ expect{api.representative_sets(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/representative-sets/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
67
67
  end
68
68
 
69
69
  it 'should raise an error if the offset is invalid' do
70
- expect{api.representative_sets(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/representative-sets/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
70
+ expect{api.representative_sets(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/representative-sets/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
71
71
  end
72
72
  end
73
73
 
@@ -78,24 +78,24 @@ describe GovKit::CA::Represent do
78
78
 
79
79
  it 'should query by postal code' do
80
80
  response = api.postcodes('A1A1A1')
81
- response.should be_a(Hash)
82
- response.should have_key('code')
81
+ expect(response).to be_a(Hash)
82
+ expect(response).to have_key('code')
83
83
  end
84
84
 
85
85
  it 'should accept an array of boundary sets' do
86
86
  response = api.postcodes('A1A1A1', :sets => ['federal-electoral-districts', 'census-subdivisions'])
87
- response.should be_a(Hash)
88
- (response['boundaries_centroid'] + response['boundaries_concordance']).should have(2).items
87
+ expect(response).to be_a(Hash)
88
+ expect((response['boundaries_centroid'] + response['boundaries_concordance']).size).to eq(2)
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
- response.should be_a(Hash)
94
- (response['boundaries_centroid'] + response['boundaries_concordance']).should have(2).items
93
+ expect(response).to be_a(Hash)
94
+ expect((response['boundaries_centroid'] + response['boundaries_concordance']).size).to eq(2)
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 https://represent.opennorth.ca/postcodes/FOO/?")
99
99
  end
100
100
  end
101
101
 
@@ -106,81 +106,81 @@ describe GovKit::CA::Represent do
106
106
 
107
107
  it 'should return boundaries' do
108
108
  response = api.boundaries
109
- response.should be_a(Hash)
110
- response.should have_key('objects')
111
- response.should have_key('meta')
112
- response['meta']['next'].should_not be_nil
109
+ expect(response).to be_a(Hash)
110
+ expect(response).to have_key('objects')
111
+ expect(response).to have_key('meta')
112
+ expect(response['meta']['next']).to_not be_nil
113
113
  end
114
114
 
115
115
  it 'should return boundaries from a boundary set' do
116
116
  response = api.boundaries(:boundary_set => 'st-johns-wards')
117
- response.should be_a(Hash)
118
- response.should have_key('objects')
119
- response.should have_key('meta')
120
- response['objects'].should have(5).items
117
+ expect(response).to be_a(Hash)
118
+ expect(response).to have_key('objects')
119
+ expect(response).to have_key('meta')
120
+ expect(response['objects'].size).to eq(5)
121
121
  end
122
122
 
123
123
  it 'should return a boundary from a boundary set' do
124
124
  response = api.boundaries(:boundary_set => 'st-johns-wards', :boundary => 'ward-1')
125
- response.should be_a(Hash)
126
- response.should have_key('related')
125
+ expect(response).to be_a(Hash)
126
+ expect(response).to have_key('related')
127
127
  end
128
128
 
129
129
  it 'should return the representatives of a boundary from a boundary set' do
130
130
  response = api.boundaries(:boundary_set => 'st-johns-wards', :boundary => 'ward-1', :representatives => true)
131
- response.should be_a(Hash)
132
- response.should have_key('objects')
133
- response.should have_key('meta')
134
- response['meta']['next'].should be_nil
131
+ expect(response).to be_a(Hash)
132
+ expect(response).to have_key('objects')
133
+ expect(response).to have_key('meta')
134
+ expect(response['meta']['next']).to be_nil
135
135
  end
136
136
 
137
137
  it 'should return boundaries from many boundary sets as an array' do
138
138
  response = api.boundaries(:sets => ['st-johns-wards','caledon-wards'])
139
- response.should be_a(Hash)
140
- response.should have_key('objects')
141
- response.should have_key('meta')
142
- response['objects'].should have(10).items
139
+ expect(response).to be_a(Hash)
140
+ expect(response).to have_key('objects')
141
+ expect(response).to have_key('meta')
142
+ expect(response['objects'].size).to eq(10)
143
143
  end
144
144
 
145
145
  it 'should return boundaries from many boundary sets as a comma-separated list' do
146
146
  response = api.boundaries(:sets => 'st-johns-wards,caledon-wards')
147
- response.should be_a(Hash)
148
- response.should have_key('objects')
149
- response.should have_key('meta')
150
- response['objects'].should have(10).items
147
+ expect(response).to be_a(Hash)
148
+ expect(response).to have_key('objects')
149
+ expect(response).to have_key('meta')
150
+ expect(response['objects'].size).to eq(10)
151
151
  end
152
152
 
153
153
  it 'should accept a point as an array' do
154
154
  response = api.boundaries(:contains => ['47.5699', '-52.6954'])
155
- response.should be_a(Hash)
156
- response.should have_key('objects')
157
- response.should have_key('meta')
158
- response['meta']['next'].should be_nil
155
+ expect(response).to be_a(Hash)
156
+ expect(response).to have_key('objects')
157
+ expect(response).to have_key('meta')
158
+ expect(response['meta']['next']).to be_nil
159
159
  end
160
160
 
161
161
  it 'should accept a point as a comma-separated list' do
162
162
  response = api.boundaries(:contains => '47.5699,-52.6954')
163
- response.should be_a(Hash)
164
- response.should have_key('objects')
165
- response.should have_key('meta')
166
- response['meta']['next'].should be_nil
163
+ expect(response).to be_a(Hash)
164
+ expect(response).to have_key('objects')
165
+ expect(response).to have_key('meta')
166
+ expect(response['meta']['next']).to be_nil
167
167
  end
168
168
 
169
169
  it 'should raise an error if the point is invalid' do
170
- expect{api.boundaries(:contains => '0,0,0')}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/boundaries/?contains=0,0,0 Invalid latitude,longitude '0,0,0' provided.")
170
+ expect{api.boundaries(:contains => '0,0,0')}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/boundaries/?contains=0,0,0 Invalid latitude,longitude '0,0,0' provided.")
171
171
  end
172
172
 
173
173
  it 'should raise an error if the boundary set does not exist' do
174
- expect{api.boundaries(:boundary_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/boundaries/foo/?")
174
+ expect{api.boundaries(:boundary_set => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 https://represent.opennorth.ca/boundaries/foo/?")
175
175
  end
176
176
 
177
177
  context 'when retrieving a boundary' do
178
178
  it 'should raise an error if the boundary set does not exist' do
179
- expect{api.boundaries(:boundary_set => 'foo', :boundary => 'ward-1')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/boundaries/foo/ward-1/?")
179
+ expect{api.boundaries(:boundary_set => 'foo', :boundary => 'ward-1')}.to raise_error(GovKit::CA::ResourceNotFound, "404 https://represent.opennorth.ca/boundaries/foo/ward-1/?")
180
180
  end
181
181
 
182
182
  it 'should raise an error if the boundary does not exist' do
183
- expect{api.boundaries(:boundary_set => 'st-johns-wards', :boundary => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 http://represent.opennorth.ca/boundaries/st-johns-wards/foo/?")
183
+ expect{api.boundaries(:boundary_set => 'st-johns-wards', :boundary => 'foo')}.to raise_error(GovKit::CA::ResourceNotFound, "404 https://represent.opennorth.ca/boundaries/st-johns-wards/foo/?")
184
184
  end
185
185
 
186
186
  it 'should raise an error if the boundary set is not given' do
@@ -207,11 +207,11 @@ describe GovKit::CA::Represent do
207
207
  end
208
208
 
209
209
  it 'should raise an error if the limit is invalid' do
210
- expect{api.boundaries(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/boundaries/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
210
+ expect{api.boundaries(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/boundaries/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
211
211
  end
212
212
 
213
213
  it 'should raise an error if the offset is invalid' do
214
- expect{api.boundaries(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/boundaries/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
214
+ expect{api.boundaries(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/boundaries/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
215
215
  end
216
216
  end
217
217
 
@@ -222,54 +222,54 @@ describe GovKit::CA::Represent do
222
222
 
223
223
  it 'should return representatives' do
224
224
  response = api.representatives
225
- response.should be_a(Hash)
226
- response.should have_key('objects')
227
- response.should have_key('meta')
228
- response['meta']['next'].should_not be_nil
225
+ expect(response).to be_a(Hash)
226
+ expect(response).to have_key('objects')
227
+ expect(response).to have_key('meta')
228
+ expect(response['meta']['next']).to_not be_nil
229
229
  end
230
230
 
231
231
  it 'should return representatives from a representative set' do
232
232
  response = api.representatives(:representative_set => 'st-johns-city-council')
233
- response.should be_a(Hash)
234
- response.should have_key('objects')
235
- response.should have_key('meta')
236
- response['meta']['next'].should be_nil
233
+ expect(response).to be_a(Hash)
234
+ expect(response).to have_key('objects')
235
+ expect(response).to have_key('meta')
236
+ expect(response['meta']['next']).to be_nil
237
237
  end
238
238
 
239
239
  it 'should accept a point as an array' do
240
240
  response = api.representatives(:point => ['47.5699', '-52.6954'])
241
- response.should be_a(Hash)
242
- response.should have_key('objects')
243
- response.should have_key('meta')
244
- response['meta']['next'].should be_nil
241
+ expect(response).to be_a(Hash)
242
+ expect(response).to have_key('objects')
243
+ expect(response).to have_key('meta')
244
+ expect(response['meta']['next']).to be_nil
245
245
  end
246
246
 
247
247
  it 'should accept a point as a comma-separated list' do
248
248
  response = api.representatives(:point => '47.5699,-52.6954')
249
- response.should be_a(Hash)
250
- response.should have_key('objects')
251
- response.should have_key('meta')
252
- response['meta']['next'].should be_nil
249
+ expect(response).to be_a(Hash)
250
+ expect(response).to have_key('objects')
251
+ expect(response).to have_key('meta')
252
+ expect(response['meta']['next']).to be_nil
253
253
  end
254
254
 
255
255
  it 'should accept an array of districts' do
256
256
  response = api.representatives(:districts => ['federal-electoral-districts/10007', 'census-subdivisions/1001519'])
257
- response.should be_a(Hash)
258
- response.should have_key('objects')
259
- response.should have_key('meta')
260
- response['meta']['next'].should be_nil
257
+ expect(response).to be_a(Hash)
258
+ expect(response).to have_key('objects')
259
+ expect(response).to have_key('meta')
260
+ expect(response['meta']['next']).to be_nil
261
261
  end
262
262
 
263
263
  it 'should accept a comma-separated list of districts' do
264
264
  response = api.representatives(:districts => 'federal-electoral-districts/10007,census-subdivisions/1001519')
265
- response.should be_a(Hash)
266
- response.should have_key('objects')
267
- response.should have_key('meta')
268
- response['meta']['next'].should be_nil
265
+ expect(response).to be_a(Hash)
266
+ expect(response).to have_key('objects')
267
+ expect(response).to have_key('meta')
268
+ expect(response['meta']['next']).to be_nil
269
269
  end
270
270
 
271
271
  it 'should raise an error if the point is invalid' do
272
- expect{api.representatives(:point => '0,0,0')}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/representatives/?point=0,0,0 Invalid latitude,longitude '0,0,0' provided.")
272
+ expect{api.representatives(:point => '0,0,0')}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/representatives/?point=0,0,0 Invalid latitude,longitude '0,0,0' provided.")
273
273
  end
274
274
 
275
275
  it 'should not raise an error if the representative set does not exist' do
@@ -277,11 +277,11 @@ describe GovKit::CA::Represent do
277
277
  end
278
278
 
279
279
  it 'should raise an error if the limit is invalid' do
280
- expect{api.representatives(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/representatives/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
280
+ expect{api.representatives(:limit => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/representatives/?limit=-1 Invalid limit '-1' provided. Please provide a positive integer >= 0.")
281
281
  end
282
282
 
283
283
  it 'should raise an error if the offset is invalid' do
284
- expect{api.representatives(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 http://represent.opennorth.ca/representatives/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
284
+ expect{api.representatives(:offset => -1)}.to raise_error(GovKit::CA::InvalidRequest, "400 https://represent.opennorth.ca/representatives/?offset=-1 Invalid offset '-1' provided. Please provide a positive integer >= 0.")
285
285
  end
286
286
  end
287
287
  end
@@ -1,18 +1,15 @@
1
1
  require 'rubygems'
2
2
 
3
+ require 'simplecov'
3
4
  require 'coveralls'
4
- Coveralls.wear!
5
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
+ SimpleCov.start do
7
+ add_filter 'spec'
8
+ end
5
9
 
6
10
  require 'rspec'
7
11
  require File.dirname(__FILE__) + '/../lib/gov_kit-ca'
8
12
 
9
- module Helpers
10
- def fixture_path(*args)
11
- File.join(File.dirname(__FILE__), 'fixtures', *args)
12
- end
13
- end
14
-
15
13
  RSpec.configure do |config|
16
- config.include Helpers
17
14
  config.filter_run_excluding :broken => true
18
15
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe GovKit::CA::PostalCode::StrategySet do
3
+ RSpec.describe GovKit::CA::PostalCode::StrategySet do
4
4
  let :strategy do
5
5
  Class.new
6
6
  end
@@ -14,27 +14,27 @@ describe GovKit::CA::PostalCode::StrategySet do
14
14
 
15
15
  describe '#strategies' do
16
16
  it 'should return the strategies' do
17
- GovKit::CA::PostalCode::StrategySet.strategies[0..4].should == [
17
+ expect(GovKit::CA::PostalCode::StrategySet.strategies[0..4]).to eq([
18
18
  GovKit::CA::PostalCode::Strategy::ElectionsCa,
19
19
  GovKit::CA::PostalCode::Strategy::LiberalCa,
20
20
  GovKit::CA::PostalCode::Strategy::NDPCa,
21
21
  # GovKit::CA::PostalCode::Strategy::GreenPartyCa,
22
22
  # GovKit::CA::PostalCode::Strategy::CBCCa,
23
23
  # GovKit::CA::PostalCode::Strategy::ConservativeCa,
24
- ]
24
+ ])
25
25
  end
26
26
  end
27
27
 
28
28
  describe '#register' do
29
29
  it 'should append a strategy' do
30
30
  GovKit::CA::PostalCode::StrategySet.register(strategy)
31
- GovKit::CA::PostalCode::StrategySet.strategies.last.should == strategy
31
+ expect(GovKit::CA::PostalCode::StrategySet.strategies.last).to eq(strategy)
32
32
  end
33
33
  end
34
34
 
35
35
  describe '#run' do
36
36
  it 'should run the strategies' do
37
- GovKit::CA::PostalCode::StrategySet.run('A1A1A1').should == [10007]
37
+ expect(GovKit::CA::PostalCode::StrategySet.run('A1A1A1')).to eq([10007])
38
38
  end
39
39
  end
40
40
  end
@@ -46,14 +46,14 @@ describe GovKit::CA::PostalCode::StrategySet do
46
46
 
47
47
  describe '#strategies' do
48
48
  it 'should return the strategies' do
49
- GovKit::CA::PostalCode::StrategySet.strategies.should == []
49
+ expect(GovKit::CA::PostalCode::StrategySet.strategies).to eq([])
50
50
  end
51
51
  end
52
52
 
53
53
  describe '#register' do
54
54
  it 'should add a strategy' do
55
55
  GovKit::CA::PostalCode::StrategySet.register(strategy)
56
- GovKit::CA::PostalCode::StrategySet.strategies.should == [strategy]
56
+ expect(GovKit::CA::PostalCode::StrategySet.strategies).to eq([strategy])
57
57
  end
58
58
  end
59
59
 
@@ -31,7 +31,7 @@ task :trim_postal_codes, :file do |t,args|
31
31
  # Get the minimum number of postal codes to cover all electoral districts.
32
32
  # This is an instance of the set cover problem, which is NP-complete. Use the
33
33
  # greedy algorithm, which is the best-possible polynomial time approximation
34
- # algorithm for set cover. http://en.wikipedia.org/wiki/Set_cover_problem
34
+ # algorithm for set cover. https://en.wikipedia.org/wiki/Set_cover_problem
35
35
  postal_codes = []
36
36
  until postal_to_edid.empty?
37
37
  postal_code, edids = postal_to_edid.max{|_,v| v.size}
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.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.6.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: json
56
+ name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,47 +67,47 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.6.0
75
+ version: '1.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.6.0
82
+ version: '1.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 10.1.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 10.1.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: coveralls
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '3.1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '3.1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: mime-types
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
133
  - ".gitignore"
134
+ - ".rspec"
134
135
  - ".travis.yml"
135
136
  - ".yardopts"
136
137
  - Gemfile
@@ -139,7 +140,6 @@ files:
139
140
  - Rakefile
140
141
  - USAGE
141
142
  - govkit-ca.gemspec
142
- - lib/data/rid_to_edid.yml
143
143
  - lib/gov_kit-ca.rb
144
144
  - lib/gov_kit-ca/postal_code.rb
145
145
  - lib/gov_kit-ca/postal_code/strategy/base.rb
@@ -155,6 +155,7 @@ files:
155
155
  - lib/gov_kit-ca/represent.rb
156
156
  - lib/gov_kit-ca/version.rb
157
157
  - lib/govkit-ca.rb
158
+ - lib/rid_to_edid.yml
158
159
  - spec/cbc_ca_spec.rb
159
160
  - spec/conservative_ca_spec.rb
160
161
  - spec/digital-copyright_ca_spec.rb
@@ -165,12 +166,11 @@ files:
165
166
  - spec/parl_gc_ca_spec.rb
166
167
  - spec/postal_code_spec.rb
167
168
  - spec/represent_spec.rb
168
- - spec/spec.opts
169
169
  - spec/spec_helper.rb
170
170
  - spec/strategy_set_spec.rb
171
171
  - tasks/postal-code-for-districts.csv
172
172
  - tasks/tasks.rb
173
- homepage: http://github.com/opennorth/govkit-ca
173
+ homepage: https://github.com/opennorth/govkit-ca
174
174
  licenses:
175
175
  - MIT
176
176
  metadata: {}
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubyforge_project: govkit-ca
192
+ rubyforge_project:
193
193
  rubygems_version: 2.2.2
194
194
  signing_key:
195
195
  specification_version: 4
@@ -205,6 +205,5 @@ test_files:
205
205
  - spec/parl_gc_ca_spec.rb
206
206
  - spec/postal_code_spec.rb
207
207
  - spec/represent_spec.rb
208
- - spec/spec.opts
209
208
  - spec/spec_helper.rb
210
209
  - spec/strategy_set_spec.rb
@@ -1,5 +0,0 @@
1
- --colour
2
- --format nested
3
- --loadby mtime
4
- --reverse
5
- --backtrace