openstates 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +37 -0
- data/README.md +6 -0
- data/Rakefile +1 -1
- data/lib/openstates.rb +0 -1
- data/lib/openstates/api.rb +13 -8
- data/lib/openstates/connection.rb +5 -2
- data/lib/openstates/mashify.rb +1 -1
- data/lib/openstates/model.rb +5 -6
- data/lib/openstates/models/bill.rb +8 -0
- data/lib/openstates/version.rb +1 -1
- data/openstates.gemspec +17 -16
- data/spec/openstates/api_spec.rb +83 -72
- data/spec/openstates/models/bill_spec.rb +41 -13
- data/spec/openstates/models/committee_spec.rb +6 -6
- data/spec/openstates/models/district_spec.rb +15 -14
- data/spec/openstates/models/event_spec.rb +6 -6
- data/spec/openstates/models/legislator_spec.rb +18 -16
- data/spec/openstates/version_spec.rb +2 -4
- data/spec/spec_helper.rb +2 -2
- metadata +20 -3
- data/Guardfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e57b5b7800bdcac08cfa5ee25329cfdc887636a
|
4
|
+
data.tar.gz: 56aae9f8bab39e246e429b925117433830022063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 961de741346cda6f4f4772bdaf988d53f5550a1adea741f23c378daad650e11a47e1eb20b26808c0693a3f630cc284c198cb74fed0f16fe77460ba1d7baa31d2
|
7
|
+
data.tar.gz: 145bf51ee52c8fded0347f6abfca4f806711aae16ed067a7833fd23903d78e9297d936a3d7b6f3924586216a31ac6960021608c7ba13ce6fbd5b01477d4637bb
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
ExtraDetails: true
|
5
|
+
|
6
|
+
Style/SpaceInsideHashLiteralBraces:
|
7
|
+
EnforcedStyle: no_space
|
8
|
+
|
9
|
+
Style/FrozenStringLiteralComment:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/SpecialGlobalVars:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/NegatedIf:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/StringLiterals:
|
22
|
+
EnforcedStyle: single_quotes
|
23
|
+
|
24
|
+
Style/DotPosition:
|
25
|
+
EnforcedStyle: leading
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Enabled: true
|
32
|
+
Max: 15
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.x Releases
|
4
|
+
- `0.2.x` Releases - [0.2.0](#020)
|
5
|
+
- `0.1.x` Releases - [0.1.0](#010)
|
6
|
+
|
7
|
+
## 0.0.x Releases
|
8
|
+
- `0.0.x` Releases - [0.0.1](#001)
|
9
|
+
|
10
|
+
---
|
11
|
+
## [0.2.0](https://github.com/wideeyelabs/ruby-openstates/releases/tag/v0.2.0)
|
12
|
+
Released on 2017-02-17
|
13
|
+
|
14
|
+
### Added
|
15
|
+
Added the ability to fetch a single bill detail via the OpenStates id
|
16
|
+
|
17
|
+
### Updated
|
18
|
+
- Style consistency throughout the codebase
|
19
|
+
|
20
|
+
### Removed
|
21
|
+
|
22
|
+
|
23
|
+
## [0.1.0](https://github.com/wideeyelabs/ruby-openstates/releases/tag/v0.1.0)
|
24
|
+
Released on 2017-01-06
|
25
|
+
|
26
|
+
### Added
|
27
|
+
|
28
|
+
### Updated
|
29
|
+
- Use https instead of http
|
30
|
+
|
31
|
+
### Removed
|
32
|
+
|
33
|
+
|
34
|
+
## [0.0.1](https://github.com/wideeyelabs/ruby-openstates/releases/tag/v0.0.1)
|
35
|
+
Released on 2013-12-01
|
36
|
+
|
37
|
+
Initial Release
|
data/README.md
CHANGED
@@ -59,6 +59,12 @@ You can also search for a specific bill by it's bill_id.
|
|
59
59
|
bill = OpenStates::Bill.find("12345")
|
60
60
|
```
|
61
61
|
|
62
|
+
Or by its OpenStates `id`.
|
63
|
+
|
64
|
+
```rb
|
65
|
+
bill = OpenStates::Bill.find_by_openstates_id("KS00012345")
|
66
|
+
```
|
67
|
+
|
62
68
|
And lastly, you can get bill details by using the `bill_details` class
|
63
69
|
method on OpenStates::Bill.
|
64
70
|
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/openstates.rb
CHANGED
data/lib/openstates/api.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module OpenStates
|
2
2
|
module Api
|
3
3
|
def metadata(state = nil)
|
4
|
-
url =
|
4
|
+
url = 'metadata/'
|
5
5
|
url << "#{state}/" if state
|
6
6
|
get(url)
|
7
7
|
end
|
8
8
|
|
9
9
|
def bills(options = {})
|
10
|
-
url =
|
10
|
+
url = 'bills/'
|
11
11
|
if options[:state] && options[:session] && options[:bill_id]
|
12
12
|
url << "#{options[:state]}/#{options[:session]}/#{options[:bill_id]}/"
|
13
13
|
[:state, :session, :bill_id].each do |key|
|
@@ -18,28 +18,33 @@ module OpenStates
|
|
18
18
|
get(url, options)
|
19
19
|
end
|
20
20
|
|
21
|
+
def bill(os_id)
|
22
|
+
url = "bills/#{os_id}/"
|
23
|
+
get(url, {})
|
24
|
+
end
|
25
|
+
|
21
26
|
def legislators(options = {})
|
22
|
-
url =
|
27
|
+
url = 'legislators/'
|
23
28
|
url << "#{options[:leg_id]}/" if options[:leg_id]
|
24
29
|
|
25
30
|
get(url, options)
|
26
31
|
end
|
27
32
|
|
28
33
|
def geo_legislators(lat, lon)
|
29
|
-
url =
|
34
|
+
url = 'legislators/geo/'
|
30
35
|
|
31
|
-
get(url,
|
36
|
+
get(url, lat: lat, long: lon)
|
32
37
|
end
|
33
38
|
|
34
39
|
def committees(options = {})
|
35
|
-
url =
|
40
|
+
url = 'committees/'
|
36
41
|
url << "#{options[:committee_id]}/" if options[:committee_id]
|
37
42
|
|
38
43
|
get(url, options)
|
39
44
|
end
|
40
45
|
|
41
46
|
def events(options = {})
|
42
|
-
url =
|
47
|
+
url = 'events/'
|
43
48
|
url << "#{options[:event_id]}/" if options[:event_id]
|
44
49
|
|
45
50
|
get(url, options)
|
@@ -48,7 +53,7 @@ module OpenStates
|
|
48
53
|
def districts(options = {})
|
49
54
|
return [] if !options[:state]
|
50
55
|
|
51
|
-
url =
|
56
|
+
url = 'districts/'
|
52
57
|
url << "#{options[:state]}/"
|
53
58
|
url << "#{options[:chamber]}/" if options[:chamber]
|
54
59
|
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module OpenStates
|
2
2
|
module Connection
|
3
|
-
BASE_URL = 'https://openstates.org/api/v1/'
|
3
|
+
BASE_URL = 'https://openstates.org/api/v1/'.freeze
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/LineLength, Metrics/AbcSize, Metrics/MethodLength
|
4
6
|
def connection
|
5
7
|
@connection ||= begin
|
6
8
|
conn = Faraday.new(BASE_URL) do |b|
|
7
9
|
b.use Faraday::Response::Logger, logger
|
8
10
|
b.use FaradayMiddleware::Mashify
|
9
11
|
b.use FaradayMiddleware::ParseJson, content_type: 'application/json'
|
10
|
-
b.use FaradayMiddleware::Caching, cache, strip_params: %w
|
12
|
+
b.use FaradayMiddleware::Caching, cache, strip_params: %w(apikey) unless cache.nil?
|
11
13
|
b.response :raise_error
|
12
14
|
b.adapter Faraday.default_adapter
|
13
15
|
end
|
@@ -17,6 +19,7 @@ module OpenStates
|
|
17
19
|
conn
|
18
20
|
end
|
19
21
|
end
|
22
|
+
# rubocop:enable Metrics/LineLength, Metrics/AbcSize, Metrics/MethodLength
|
20
23
|
|
21
24
|
def get(path, params = nil)
|
22
25
|
response = connection.get(path) do |request|
|
data/lib/openstates/mashify.rb
CHANGED
data/lib/openstates/model.rb
CHANGED
@@ -24,7 +24,7 @@ module OpenStates
|
|
24
24
|
def find(id)
|
25
25
|
return if !id
|
26
26
|
|
27
|
-
id_hash =
|
27
|
+
id_hash = {}
|
28
28
|
id_hash[id_key] = id
|
29
29
|
response = OpenStates.send(api_method, id_hash)
|
30
30
|
|
@@ -52,12 +52,11 @@ module OpenStates
|
|
52
52
|
return unless hash
|
53
53
|
|
54
54
|
hash.each do |key, value|
|
55
|
+
next if value.nil?
|
56
|
+
|
55
57
|
set_attr_method = "#{key}="
|
56
|
-
|
57
|
-
|
58
|
-
self.__send__(set_attr_method, value)
|
59
|
-
end
|
60
|
-
end
|
58
|
+
|
59
|
+
__send__(set_attr_method, value) if respond_to?(set_attr_method)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/openstates/version.rb
CHANGED
data/openstates.gemspec
CHANGED
@@ -4,26 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'openstates/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'openstates'
|
8
8
|
spec.version = OpenStates::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Chris']
|
10
|
+
spec.email = ['chris@wideeyelabs.com']
|
11
|
+
spec.summary = 'Ruby gem to interact with the OpenStates API.'
|
12
|
+
spec.description = 'Ruby gem to interact with the OpenStates API.'
|
13
|
+
spec.homepage = 'https://github.com/WideEyeLabs'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
21
|
+
spec.add_dependency 'faraday_middleware'
|
22
|
+
spec.add_dependency 'hashie'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'pry-remote'
|
28
|
+
spec.add_development_dependency 'pry-byebug'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
29
30
|
end
|
data/spec/openstates/api_spec.rb
CHANGED
@@ -1,182 +1,193 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::Api do
|
4
|
-
before { OpenStates.
|
4
|
+
before(:each) { allow(OpenStates).to receive(:get).and_return({}) }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe '.metadata' do
|
7
|
+
it 'calls .get on OpenStates' do
|
8
8
|
expect(OpenStates).to receive(:get)
|
9
9
|
OpenStates.metadata
|
10
10
|
end
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
expect(OpenStates).to receive(:get).with(
|
12
|
+
context 'without a state passed' do
|
13
|
+
it 'calls .get with metadata/' do
|
14
|
+
expect(OpenStates).to receive(:get).with('metadata/')
|
15
15
|
OpenStates.metadata
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
context
|
20
|
-
it
|
21
|
-
state =
|
19
|
+
context 'with a state passed in' do
|
20
|
+
it 'calls .get with metadata/in/' do
|
21
|
+
state = 'in'
|
22
22
|
expect(OpenStates).to receive(:get).with("metadata/#{state}/")
|
23
23
|
OpenStates.metadata(state)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
28
|
+
describe '.bills' do
|
29
|
+
it 'calls .get on OpenStates' do
|
30
30
|
expect(OpenStates).to receive(:get)
|
31
31
|
OpenStates.bills
|
32
32
|
end
|
33
33
|
|
34
|
-
context
|
35
|
-
it
|
36
|
-
expect(OpenStates).to receive(:get).with(
|
34
|
+
context 'without an options hash passed' do
|
35
|
+
it 'calls .get with bills/ and an empty hash' do
|
36
|
+
expect(OpenStates).to receive(:get).with('bills/', {})
|
37
37
|
OpenStates.bills
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
context
|
42
|
-
it
|
43
|
-
options = {:
|
44
|
-
expect(OpenStates).to receive(:get).with(
|
41
|
+
context 'with an options hash passed' do
|
42
|
+
it 'calls .get with bills/in/summer/10 and an options hash' do
|
43
|
+
options = {state: 'in', session: 'summer', bill_id: 10}
|
44
|
+
expect(OpenStates).to receive(:get).with(
|
45
|
+
"bills/#{options[:state]}/#{options[:session]}/#{options[:bill_id]}/",
|
46
|
+
options
|
47
|
+
)
|
45
48
|
OpenStates.bills(options)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
describe
|
51
|
-
it
|
53
|
+
describe '.legislators' do
|
54
|
+
it 'calls .get on OpenStates' do
|
52
55
|
expect(OpenStates).to receive(:get)
|
53
56
|
OpenStates.legislators
|
54
57
|
end
|
55
58
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
expect(OpenStates).to receive(:get).with(
|
59
|
+
context 'without an options hash passed' do
|
60
|
+
it 'calls .get with legislators/ and an empty hash' do
|
61
|
+
expect(OpenStates).to receive(:get).with('legislators/', {})
|
59
62
|
OpenStates.legislators
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
63
|
-
context
|
64
|
-
it
|
65
|
-
options = {:
|
66
|
-
expect(OpenStates).to receive(:get)
|
66
|
+
context 'with an options hash passed' do
|
67
|
+
it 'calls .get with legislators/ and an options hash' do
|
68
|
+
options = {leg_id: 1}
|
69
|
+
expect(OpenStates).to receive(:get)
|
70
|
+
.with("legislators/#{options[:leg_id]}/", options)
|
67
71
|
OpenStates.legislators(options)
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
72
|
-
describe
|
73
|
-
it
|
76
|
+
describe '.geo_legislators' do
|
77
|
+
it 'calls .get on OpenStates' do
|
74
78
|
expect(OpenStates).to receive(:get)
|
75
79
|
OpenStates.geo_legislators(nil, nil)
|
76
80
|
end
|
77
81
|
|
78
|
-
it
|
79
|
-
lat
|
80
|
-
|
82
|
+
it 'calls .get with legislators/geo/ and a hash with lat/lon' do
|
83
|
+
lat = 10
|
84
|
+
lon = 10
|
85
|
+
expect(OpenStates).to receive(:get)
|
86
|
+
.with('legislators/geo/', lat: lat, long: lon)
|
81
87
|
OpenStates.geo_legislators(lat, lon)
|
82
88
|
end
|
83
89
|
end
|
84
90
|
|
85
|
-
describe
|
86
|
-
it
|
91
|
+
describe '.committees' do
|
92
|
+
it 'calls .get on OpenStates' do
|
87
93
|
expect(OpenStates).to receive(:get)
|
88
94
|
OpenStates.committees
|
89
95
|
end
|
90
96
|
|
91
|
-
context
|
92
|
-
it
|
93
|
-
expect(OpenStates).to receive(:get).with(
|
97
|
+
context 'without an options hash passed' do
|
98
|
+
it 'calls .get with committees/ and an empty hash' do
|
99
|
+
expect(OpenStates).to receive(:get).with('committees/', {})
|
94
100
|
OpenStates.committees
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
98
|
-
context
|
99
|
-
it
|
100
|
-
options = {:
|
101
|
-
expect(OpenStates).to receive(:get)
|
104
|
+
context 'with an options hash passed' do
|
105
|
+
it 'calls .get with committees/ and an options hash' do
|
106
|
+
options = {committee_id: 1}
|
107
|
+
expect(OpenStates).to receive(:get)
|
108
|
+
.with("committees/#{options[:committee_id]}/", options)
|
102
109
|
OpenStates.committees(options)
|
103
110
|
end
|
104
111
|
end
|
105
112
|
end
|
106
113
|
|
107
|
-
describe
|
108
|
-
it
|
114
|
+
describe '.events' do
|
115
|
+
it 'calls .get on OpenStates' do
|
109
116
|
expect(OpenStates).to receive(:get)
|
110
117
|
OpenStates.events
|
111
118
|
end
|
112
119
|
|
113
|
-
context
|
114
|
-
it
|
115
|
-
expect(OpenStates).to receive(:get).with(
|
120
|
+
context 'without an options hash passed' do
|
121
|
+
it 'calls .get with events/ and an empty hash' do
|
122
|
+
expect(OpenStates).to receive(:get).with('events/', {})
|
116
123
|
OpenStates.events
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|
120
|
-
context
|
121
|
-
it
|
122
|
-
options = {:
|
123
|
-
expect(OpenStates).to receive(:get)
|
127
|
+
context 'with an options hash passed' do
|
128
|
+
it 'calls .get with events/ and an options hash' do
|
129
|
+
options = {event_id: 1}
|
130
|
+
expect(OpenStates).to receive(:get)
|
131
|
+
.with("events/#{options[:event_id]}/", options)
|
124
132
|
OpenStates.events(options)
|
125
133
|
end
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
129
|
-
describe
|
130
|
-
context
|
131
|
-
it
|
137
|
+
describe '.districts' do
|
138
|
+
context 'without an options hash passed' do
|
139
|
+
it 'returns an Array' do
|
132
140
|
expect(OpenStates.districts).to be_an Array
|
133
141
|
end
|
134
142
|
|
135
|
-
it
|
143
|
+
it 'returns an empty Array' do
|
136
144
|
expect(OpenStates.districts).to be_empty
|
137
145
|
end
|
138
146
|
end
|
139
147
|
|
140
|
-
context
|
141
|
-
context
|
142
|
-
it
|
148
|
+
context 'with an options hash passed' do
|
149
|
+
context 'with a state key only' do
|
150
|
+
it 'calls .get on OpenStates' do
|
143
151
|
expect(OpenStates).to receive(:get)
|
144
152
|
OpenStates.districts(state: 'fl')
|
145
153
|
end
|
146
154
|
|
147
|
-
it
|
148
|
-
options = {:
|
149
|
-
expect(OpenStates).to receive(:get)
|
155
|
+
it 'calls .get with districts/ and an options hash' do
|
156
|
+
options = {state: 'oh'}
|
157
|
+
expect(OpenStates).to receive(:get)
|
158
|
+
.with("districts/#{options[:state]}/", options)
|
150
159
|
OpenStates.districts(options)
|
151
160
|
end
|
152
161
|
end
|
153
162
|
|
154
|
-
context
|
155
|
-
it
|
156
|
-
options = {:
|
157
|
-
expect(OpenStates).to receive(:get)
|
163
|
+
context 'with a state and chamber key' do
|
164
|
+
it 'calls .get with districts/ and an options hash' do
|
165
|
+
options = {state: 'in', chamber: 'blah'}
|
166
|
+
expect(OpenStates).to receive(:get)
|
167
|
+
.with("districts/#{options[:state]}/#{options[:chamber]}/", options)
|
158
168
|
OpenStates.districts(options)
|
159
169
|
end
|
160
170
|
end
|
161
171
|
end
|
162
172
|
end
|
163
173
|
|
164
|
-
describe
|
174
|
+
describe '.district_boundaries' do
|
165
175
|
let(:boundary_id) { 1 }
|
166
|
-
it
|
176
|
+
it 'calls .get on OpenStates' do
|
167
177
|
expect(OpenStates).to receive(:get)
|
168
178
|
OpenStates.district_boundaries(boundary_id)
|
169
179
|
end
|
170
180
|
|
171
|
-
context
|
172
|
-
it
|
173
|
-
expect(OpenStates).to receive(:get)
|
181
|
+
context 'with a boundary_id parameter' do
|
182
|
+
it 'calls .get with districts/:boundary_id' do
|
183
|
+
expect(OpenStates).to receive(:get)
|
184
|
+
.with("districts/boundary/#{boundary_id}/")
|
174
185
|
OpenStates.district_boundaries(boundary_id)
|
175
186
|
end
|
176
187
|
end
|
177
188
|
|
178
|
-
context
|
179
|
-
it
|
189
|
+
context 'without a boundary_id parameter' do
|
190
|
+
it 'returns nil' do
|
180
191
|
expect(OpenStates.district_boundaries(nil)).to be_nil
|
181
192
|
end
|
182
193
|
end
|
@@ -1,32 +1,60 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::Bill do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect{ OpenStates::Bill.api_method }.not_to raise_error
|
4
|
+
describe '.api_method' do
|
5
|
+
it 'does not raise a NotImplementedError' do
|
6
|
+
expect { OpenStates::Bill.api_method }.not_to raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect{ OpenStates::Bill.id_key }.not_to raise_error
|
10
|
+
describe '.id_key' do
|
11
|
+
it 'does not raise a NotImplementedError' do
|
12
|
+
expect { OpenStates::Bill.id_key }.not_to raise_error
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
context
|
18
|
-
it
|
16
|
+
describe '.bill_details' do
|
17
|
+
context 'when state, session, and bill_id are nil' do
|
18
|
+
it 'returns nil' do
|
19
19
|
expect(OpenStates::Bill.bill_details(nil, nil, nil)).to be_nil
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
24
|
-
it
|
23
|
+
context 'when state, session, and bill_id are not nil' do
|
24
|
+
it 'returns an OpenState::Bill' do
|
25
25
|
state = 'fl'
|
26
26
|
session = '2013'
|
27
27
|
bill_id = '1234'
|
28
|
-
|
29
|
-
OpenStates
|
28
|
+
|
29
|
+
allow(OpenStates).to receive(:bills).and_return(
|
30
|
+
bill_id: bill_id, state: state, session: session
|
31
|
+
)
|
32
|
+
|
33
|
+
expect(
|
34
|
+
OpenStates::Bill.bill_details(state, session, bill_id)
|
35
|
+
).to be_a described_class
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.find_by_openstates_id' do
|
41
|
+
context 'openstates id is legit' do
|
42
|
+
it 'returns a Bill' do
|
43
|
+
openstate_bill_id = 'KSB00005007'
|
44
|
+
|
45
|
+
allow(OpenStates).to receive(:bill).and_return(
|
46
|
+
id: openstate_bill_id
|
47
|
+
)
|
48
|
+
|
49
|
+
expect(
|
50
|
+
OpenStates::Bill.find_by_openstates_id('KSB00005007')
|
51
|
+
).to be_a described_class
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when openstate_bill_id is nil' do
|
56
|
+
it 'returns nil' do
|
57
|
+
expect(OpenStates::Bill.find_by_openstates_id(nil)).to be_nil
|
30
58
|
end
|
31
59
|
end
|
32
60
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::Committee do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect{ OpenStates::Committee.api_method }.not_to raise_error
|
4
|
+
describe '.api_method' do
|
5
|
+
it 'does not raise a NotImplementedError' do
|
6
|
+
expect { OpenStates::Committee.api_method }.not_to raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect{ OpenStates::Committee.id_key }.not_to raise_error
|
10
|
+
describe '.id_key' do
|
11
|
+
it 'does not raise a NotImplementedError' do
|
12
|
+
expect { OpenStates::Committee.id_key }.not_to raise_error
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,33 +1,34 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::District do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect{ OpenStates::District.api_method }.not_to raise_error
|
4
|
+
describe '.api_method' do
|
5
|
+
it 'does not raise a NotImplementedError' do
|
6
|
+
expect { OpenStates::District.api_method }.not_to raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect{ OpenStates::District.id_key }.not_to raise_error
|
10
|
+
describe '.id_key' do
|
11
|
+
it 'does not raise a NotImplementedError' do
|
12
|
+
expect { OpenStates::District.id_key }.not_to raise_error
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe '.find' do
|
17
17
|
before(:each) do
|
18
|
-
OpenStates.
|
18
|
+
allow(OpenStates).to receive(:district_boundaries)
|
19
|
+
.and_return(state: 'il')
|
19
20
|
end
|
20
21
|
|
21
|
-
context
|
22
|
-
it
|
22
|
+
context 'without a boundary id' do
|
23
|
+
it 'returns nil' do
|
23
24
|
expect(OpenStates::District.find(nil)).to be_nil
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
context
|
28
|
-
it
|
29
|
-
options = {
|
30
|
-
expect(OpenStates::District.find(options)).to be_a
|
28
|
+
context 'with a boundary id' do
|
29
|
+
it 'returns an OpenState::District' do
|
30
|
+
options = {state: 'il'}
|
31
|
+
expect(OpenStates::District.find(options)).to be_a described_class
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::Event do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect{ OpenStates::Event.api_method }.not_to raise_error
|
4
|
+
describe '.api_method' do
|
5
|
+
it 'does not raise a NotImplementedError' do
|
6
|
+
expect { OpenStates::Event.api_method }.not_to raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect{ OpenStates::Event.id_key }.not_to raise_error
|
10
|
+
describe '.id_key' do
|
11
|
+
it 'does not raise a NotImplementedError' do
|
12
|
+
expect { OpenStates::Event.id_key }.not_to raise_error
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OpenStates::Legislator do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect{ OpenStates::Legislator.api_method }.not_to raise_error
|
4
|
+
describe '.api_method' do
|
5
|
+
it 'does not raise a NotImplementedError' do
|
6
|
+
expect { OpenStates::Legislator.api_method }.not_to raise_error
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect{ OpenStates::Legislator.id_key }.not_to raise_error
|
10
|
+
describe '.id_key' do
|
11
|
+
it 'does not raise a NotImplementedError' do
|
12
|
+
expect { OpenStates::Legislator.id_key }.not_to raise_error
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
context
|
18
|
-
it
|
19
|
-
OpenStates::Legislator.by_location(nil,nil).
|
16
|
+
describe '.by_location' do
|
17
|
+
context 'when lat and lon are nil' do
|
18
|
+
it 'does return nil' do
|
19
|
+
expect(OpenStates::Legislator.by_location(nil, nil)).to be_nil
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context 'when lat and lon are not nil' do
|
24
24
|
before(:each) do
|
25
25
|
legislator_hash = {leg_id: '1', first_name: 'bob'}
|
26
26
|
response = [legislator_hash, legislator_hash]
|
27
|
-
OpenStates.
|
27
|
+
allow(OpenStates).to receive(:geo_legislators).and_return(response)
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
|
30
|
+
it 'does return an array' do
|
31
|
+
expect(
|
32
|
+
OpenStates::Legislator.by_location(123.10, -85.20)
|
33
|
+
).to be_an Array
|
32
34
|
end
|
33
35
|
|
34
|
-
it
|
36
|
+
it 'does return an array of legislator objects' do
|
35
37
|
OpenStates::Legislator.by_location(123.10, -85.20).each do |obj|
|
36
|
-
obj.
|
38
|
+
expect(obj).to be_a OpenStates::Legislator
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
3
4
|
require 'openstates'
|
4
5
|
require 'pry'
|
5
6
|
require 'pry-remote'
|
6
|
-
require 'pry-
|
7
|
+
require 'pry-byebug'
|
7
8
|
|
8
9
|
RSpec.configure do |config|
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
10
|
config.run_all_when_everything_filtered = true
|
11
11
|
config.filter_run :focus
|
12
12
|
config.order = 'random'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: Ruby gem to interact with the OpenStates API.
|
126
140
|
email:
|
127
141
|
- chris@wideeyelabs.com
|
@@ -130,10 +144,13 @@ extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
146
|
- ".gitignore"
|
147
|
+
- ".hound.yml"
|
133
148
|
- ".rspec"
|
149
|
+
- ".rubocop.yml"
|
134
150
|
- ".ruby-version"
|
151
|
+
- ".travis.yml"
|
152
|
+
- CHANGELOG.md
|
135
153
|
- Gemfile
|
136
|
-
- Guardfile
|
137
154
|
- LICENSE.txt
|
138
155
|
- README.md
|
139
156
|
- Rakefile
|
data/Guardfile
DELETED