civic_aide 0.0.2 → 0.0.3

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: c244c9c33d9aad818c0bbfddee7bbad1433d17c4
4
- data.tar.gz: 5d9cc539c867e4beef9fe79fb5daf30045dfcf41
3
+ metadata.gz: 56f970f6dbdf0bc676809891902697c3324486bd
4
+ data.tar.gz: d2a0e07abf8aa8f9b4d2daebcb7f676593b66963
5
5
  SHA512:
6
- metadata.gz: 80888f09d7915a55886857bbcb25360c4c09f95de6e6ca67a79d4a8dd71a8a8d975b0346b231ff6760ad19271db4b83fc286f98d13fcd5200c929d1d8fb7453d
7
- data.tar.gz: cf5c1e8c46b12d63d042a0be58831cddae3000f385e56ebf4e3cbc791b61f4388fbb354d16ec610e19da4398c124d792afb33c2372439f698216726236174885
6
+ metadata.gz: 2555271f3b409f60053278b35beb6ec27af35ee21893862d32eadda81302e13fa6b503ea21982ff8c79ac165cc63fa213b807143c858f67d2ff5d47281ab03ed
7
+ data.tar.gz: 226a43e8c8d7e65d2b38f19102620e597f7e98fd7b705aac2abbb6441884a8d2331e436527c4b43a4d6befc31f8ec188ab6d25171ec901624cca589d72c381c7
data/README.md CHANGED
@@ -42,11 +42,11 @@ google_api_key = `ABCaSyD5aMsdmaXxHc7aiUyYuVXtCICV-y_PWnf5w`
42
42
  client = CivicAide::Client.new(google_api_key)
43
43
  ```
44
44
 
45
- Alternatively, the API key can be set with global configuration.
45
+ Alternatively, the API key can be set with global configuration and the resources can be accessed directly.
46
46
 
47
47
  ```ruby
48
48
  CivicAide.api_key = "ABCaSyD5aMsdmaXxHc7aiUyYuVXtCICV-y_PWnf5w"
49
- client = CivicAide::Client.new
49
+ CivicAide.elections.all
50
50
  ```
51
51
 
52
52
  ## Resources
@@ -50,7 +50,7 @@ module CivicAide
50
50
 
51
51
  def format_response(body)
52
52
  body = JSON.parse(body)
53
- body.change_zip! # to prevent Array#zip clashing when rubifying the keys
53
+ body.change_zip! # to prevent Array#zip clashing when rubyifying the keys
54
54
  body.rubyify_keys!
55
55
  Hashie::Mash.new(body)
56
56
  end
@@ -15,10 +15,6 @@ class Hash
15
15
  self
16
16
  end
17
17
 
18
- def except(*keys)
19
- dup.except!(*keys)
20
- end
21
-
22
18
  def except!(*keys)
23
19
  keys.each { |key| delete(key) }
24
20
  self
@@ -1,3 +1,3 @@
1
1
  module CivicAide
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe CivicAide do
4
+
5
+ before do
6
+ CivicAide.api_key = "samplekey"
7
+ end
8
+
9
+ it 'should include Forwardable' do
10
+ CivicAide.extend(Forwardable)
11
+ end
12
+
13
+ describe ".representatives" do
14
+ it "should include representatives" do
15
+ expect(CivicAide).to respond_to(:representatives)
16
+ end
17
+ end
18
+
19
+ describe ".elections" do
20
+ it "should include elections" do
21
+ expect(CivicAide).to respond_to(:elections)
22
+ end
23
+ end
24
+
25
+ end
@@ -8,6 +8,7 @@ describe CivicAide::Client do
8
8
 
9
9
  describe '.new' do
10
10
  it 'raises an error with no API key' do
11
+ CivicAide.api_key = nil
11
12
  expect{ CivicAide::Client.new }.to raise_error(APIKeyNotSet)
12
13
  end
13
14
 
@@ -43,7 +44,7 @@ describe CivicAide::Client do
43
44
 
44
45
  describe '#default_query' do
45
46
  it 'should have the api key' do
46
- @client.send(:default_query).should == {:key => @client.api_key, :prettyPrint => false}
47
+ expect(@client.send(:default_query)).to eq({:key => @client.api_key, :prettyPrint => false})
47
48
  end
48
49
  end
49
50
 
@@ -59,4 +60,46 @@ describe CivicAide::Client do
59
60
  end
60
61
  end
61
62
 
63
+ describe "#classify_error" do
64
+ it "should raise an error with NoAddressParameter" do
65
+ expect{ @client.send(:check_response_status, "noAddressParameter") }.to raise_error("NoAddressParameter")
66
+ end
67
+
68
+ it "should raise an error with ElectionIdMissing" do
69
+ expect{ @client.send(:check_response_status, "electionIdMissing") }.to raise_error("ElectionIdMissing")
70
+ end
71
+
72
+ it "should raise an error with NoStreetSegmentFound" do
73
+ expect{ @client.send(:check_response_status, "noStreetSegmentFound") }.to raise_error("NoStreetSegmentFound")
74
+ end
75
+
76
+ it "should raise an error with AddressUnparseable" do
77
+ expect{ @client.send(:check_response_status, "addressUnparseable") }.to raise_error("AddressUnparseable")
78
+ end
79
+
80
+ it "should raise an error with NoAddressParameter" do
81
+ expect{ @client.send(:check_response_status, "noAddressParameter") }.to raise_error("NoAddressParameter")
82
+ end
83
+
84
+ it "should raise an error with MultipleStreetSegmentsFound" do
85
+ expect{ @client.send(:check_response_status, "multipleStreetSegmentsFound") }.to raise_error("MultipleStreetSegmentsFound")
86
+ end
87
+
88
+ it "should raise an error with ElectionOver" do
89
+ expect{ @client.send(:check_response_status, "electionOver") }.to raise_error("ElectionOver")
90
+ end
91
+
92
+ it "should raise an error with ElectionUnknown" do
93
+ expect{ @client.send(:check_response_status, "electionUnknown") }.to raise_error("ElectionUnknown")
94
+ end
95
+
96
+ it "should raise an error with InternalLookupFailure" do
97
+ expect{ @client.send(:check_response_status, "internalLookupFailure") }.to raise_error("InternalLookupFailure")
98
+ end
99
+
100
+ it "should not raise an error" do
101
+ expect{ @client.send(:check_response_status, "success") }.to_not raise_error
102
+ end
103
+ end
104
+
62
105
  end
@@ -22,16 +22,6 @@ describe Hash do
22
22
 
23
23
  end
24
24
 
25
- context ".except" do
26
-
27
- it "should remove the correct item" do
28
- deleted = {:one => "hello", :two => "hello"}
29
- deleted = deleted.except(:two)
30
- expect(deleted).to eq({:one => "hello"})
31
- end
32
-
33
- end
34
-
35
25
  context ".except!" do
36
26
 
37
27
  it "should remove the correct item" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civic_aide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Pearson
@@ -131,6 +131,7 @@ files:
131
131
  - lib/civic_aide/representatives.rb
132
132
  - lib/civic_aide/string.rb
133
133
  - lib/civic_aide/version.rb
134
+ - spec/civic_aide/civic_aide_spec.rb
134
135
  - spec/civic_aide/client_spec.rb
135
136
  - spec/civic_aide/elections_spec.rb
136
137
  - spec/civic_aide/errors_spec.rb
@@ -166,6 +167,7 @@ signing_key:
166
167
  specification_version: 4
167
168
  summary: A Ruby wrapper for the Google Civic Information API
168
169
  test_files:
170
+ - spec/civic_aide/civic_aide_spec.rb
169
171
  - spec/civic_aide/client_spec.rb
170
172
  - spec/civic_aide/elections_spec.rb
171
173
  - spec/civic_aide/errors_spec.rb