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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54bc4b599a448cce3390ad41081fa947d9fc1ea7
4
- data.tar.gz: 2abd48ee2bd954dc8de98abebe8f1bcfd08ae680
3
+ metadata.gz: 4e57b5b7800bdcac08cfa5ee25329cfdc887636a
4
+ data.tar.gz: 56aae9f8bab39e246e429b925117433830022063
5
5
  SHA512:
6
- metadata.gz: e8589886070d20f45029466d77e45de96b09a3020a2aa6d27e16be36ea17d102aaa0ad5987b5fd52106853cc36be155775f6fcbfb9a0bf35511a8dad4fcd38f5
7
- data.tar.gz: 419adea1911286dc3fc60a1d171eafd0380eeba57f55f9b15061696f1317c174776208f0e4a3f084440ade7bdef16a8dff6aa0e72468a7358e305aaee192f6b8
6
+ metadata.gz: 961de741346cda6f4f4772bdaf988d53f5550a1adea741f23c378daad650e11a47e1eb20b26808c0693a3f630cc284c198cb74fed0f16fe77460ba1d7baa31d2
7
+ data.tar.gz: 145bf51ee52c8fded0347f6abfca4f806711aae16ed067a7833fd23903d78e9297d936a3d7b6f3924586216a31ac6960021608c7ba13ce6fbd5b01477d4637bb
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
@@ -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
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+
3
+ script:
4
+ - bundle
5
+ - bundle exec rspec spec
6
+
7
+ branches:
8
+ only:
9
+ - master
@@ -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 "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -1,5 +1,4 @@
1
1
  require 'openstates/core'
2
2
 
3
3
  module OpenStates
4
-
5
4
  end
@@ -1,13 +1,13 @@
1
1
  module OpenStates
2
2
  module Api
3
3
  def metadata(state = nil)
4
- url = "metadata/"
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 = "bills/"
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 = "legislators/"
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 = "legislators/geo/"
34
+ url = 'legislators/geo/'
30
35
 
31
- get(url, {:lat => lat, :long => lon})
36
+ get(url, lat: lat, long: lon)
32
37
  end
33
38
 
34
39
  def committees(options = {})
35
- url = "committees/"
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 = "events/"
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 = "districts/"
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[apikey] unless cache.nil?
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|
@@ -3,7 +3,7 @@ require 'faraday'
3
3
  module OpenStates
4
4
  class Mashify < Faraday::Response::Middleware
5
5
  def on_complete(env)
6
- super if Hash === env[:body]
6
+ super if env[:body].is_a? Hash
7
7
  end
8
8
 
9
9
  def parse(body)
@@ -24,7 +24,7 @@ module OpenStates
24
24
  def find(id)
25
25
  return if !id
26
26
 
27
- id_hash = Hash.new
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
- unless value.nil?
57
- if respond_to?(set_attr_method)
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
@@ -48,6 +48,14 @@ module OpenStates
48
48
 
49
49
  from_hash(response)
50
50
  end
51
+
52
+ def find_by_openstates_id(os_id)
53
+ return if !os_id
54
+
55
+ response = OpenStates.bill(os_id)
56
+
57
+ from_hash(response)
58
+ end
51
59
  end
52
60
  end
53
61
  end
@@ -1,3 +1,3 @@
1
1
  module OpenStates
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -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 = "openstates"
7
+ spec.name = 'openstates'
8
8
  spec.version = OpenStates::VERSION
9
- spec.authors = ["Chris"]
10
- spec.email = ["chris@wideeyelabs.com"]
11
- spec.summary = %q{Ruby gem to interact with the OpenStates API.}
12
- spec.description = %q{Ruby gem to interact with the OpenStates API.}
13
- spec.homepage = "https://github.com/WideEyeLabs"
14
- spec.license = "MIT"
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 = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
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"
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
@@ -1,182 +1,193 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe OpenStates::Api do
4
- before { OpenStates.stub(:get).and_return({}) }
4
+ before(:each) { allow(OpenStates).to receive(:get).and_return({}) }
5
5
 
6
- describe ".metadata" do
7
- it "should call .get on OpenStates" do
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 "without a state passed" do
13
- it "should call .get with 'metadata/'" do
14
- expect(OpenStates).to receive(:get).with("metadata/")
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 "with a state passed in" do
20
- it "should call .get with 'metadata/in/'" do
21
- state = "in"
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 ".bills" do
29
- it "should call .get on OpenStates" do
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 "without an options hash passed" do
35
- it "should call .get with 'bills/' and an empty hash" do
36
- expect(OpenStates).to receive(:get).with("bills/", {})
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 "with an options hash passed" do
42
- it "should call .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("bills/#{options[:state]}/#{options[:session]}/#{options[:bill_id]}/", options)
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 ".legislators" do
51
- it "should call .get on OpenStates" do
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 "without an options hash passed" do
57
- it "should call .get with 'legislators/' and an empty hash" do
58
- expect(OpenStates).to receive(:get).with("legislators/", {})
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 "with an options hash passed" do
64
- it "should call .get with 'legislators/' and an options hash" do
65
- options = {:leg_id => 1}
66
- expect(OpenStates).to receive(:get).with("legislators/#{options[:leg_id]}/", options)
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 ".geo_legislators" do
73
- it "should call .get on OpenStates" do
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 "should call .get with 'legislators/geo/' and a hash with lat/lon" do
79
- lat, lon = 10,10
80
- expect(OpenStates).to receive(:get).with("legislators/geo/", {:lat => lat, :long => lon})
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 ".committees" do
86
- it "should call .get on OpenStates" do
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 "without an options hash passed" do
92
- it "should call .get with 'committees/' and an empty hash" do
93
- expect(OpenStates).to receive(:get).with("committees/", {})
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 "with an options hash passed" do
99
- it "should call .get with 'committees/' and an options hash" do
100
- options = {:committee_id => 1}
101
- expect(OpenStates).to receive(:get).with("committees/#{options[:committee_id]}/", options)
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 ".events" do
108
- it "should call .get on OpenStates" do
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 "without an options hash passed" do
114
- it "should call .get with 'events/' and an empty hash" do
115
- expect(OpenStates).to receive(:get).with("events/", {})
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 "with an options hash passed" do
121
- it "should call .get with 'events/' and an options hash" do
122
- options = {:event_id => 1}
123
- expect(OpenStates).to receive(:get).with("events/#{options[:event_id]}/", options)
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 ".districts" do
130
- context "without an options hash passed" do
131
- it "should return an Array" do
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 "should return an empty Array" do
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 "with an options hash passed" do
141
- context "with a state key only" do
142
- it "should call .get on OpenStates" do
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 "should call .get with 'districts/' and an options hash" do
148
- options = {:state => 'oh'}
149
- expect(OpenStates).to receive(:get).with("districts/#{options[:state]}/", options)
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 "with a state and chamber key" do
155
- it "should call .get with 'districts/' and an options hash" do
156
- options = {:state => 'in', :chamber => "blah"}
157
- expect(OpenStates).to receive(:get).with("districts/#{options[:state]}/#{options[:chamber]}/", options)
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 ".district_boundaries" do
174
+ describe '.district_boundaries' do
165
175
  let(:boundary_id) { 1 }
166
- it "should call .get on OpenStates" do
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 "with a boundary_id parameter" do
172
- it "should call .get with 'districts/:boundary_id'" do
173
- expect(OpenStates).to receive(:get).with("districts/boundary/#{boundary_id}/")
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 "without a boundary_id parameter" do
179
- it "should return nil" do
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 ".api_method" do
5
- it "should not raise a NotImplementedError" do
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 ".id_key" do
11
- it "should not raise a NotImplementedError" do
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 ".bill_details" do
17
- context "when state, session, and bill_id are nil" do
18
- it "should return nil" do
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 "when state, session, and bill_id are not nil" do
24
- it "should return an OpenState::Bill" do
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
- OpenStates.stub(:bills).and_return({:bill_id => bill_id, :state => state, :session => session})
29
- OpenStates::Bill.bill_details(state, session, bill_id).should be_a OpenStates::Bill
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 ".api_method" do
5
- it "should not raise a NotImplementedError" do
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 ".id_key" do
11
- it "should not raise a NotImplementedError" do
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 ".api_method" do
5
- it "should not raise a NotImplementedError" do
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 ".id_key" do
11
- it "should not raise a NotImplementedError" do
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 ".find" do
16
+ describe '.find' do
17
17
  before(:each) do
18
- OpenStates.stub(:district_boundaries).and_return({ :state => 'il' })
18
+ allow(OpenStates).to receive(:district_boundaries)
19
+ .and_return(state: 'il')
19
20
  end
20
21
 
21
- context "without a boundary id" do
22
- it "should return nil" do
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 "with a boundary id" do
28
- it "should return an OpenState::District" do
29
- options = { :state => 'il' }
30
- expect(OpenStates::District.find(options)).to be_a OpenStates::District
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 ".api_method" do
5
- it "should not raise a NotImplementedError" do
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 ".id_key" do
11
- it "should not raise a NotImplementedError" do
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 ".api_method" do
5
- it "should not raise a NotImplementedError" do
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 ".id_key" do
11
- it "should not raise a NotImplementedError" do
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 ".by_location" do
17
- context "when lat and lon are nil" do
18
- it "should return nil" do
19
- OpenStates::Legislator.by_location(nil,nil).should be_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 "when lat and lon are not nil" do
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.stub(:geo_legislators).and_return(response)
27
+ allow(OpenStates).to receive(:geo_legislators).and_return(response)
28
28
  end
29
29
 
30
- it "should return an array" do
31
- OpenStates::Legislator.by_location(123.10, -85.20).should be_an Array
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 "should return an array of legislator objects" do
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.should be_a OpenStates::Legislator
38
+ expect(obj).to be_a OpenStates::Legislator
37
39
  end
38
40
  end
39
41
  end
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OpenStates::VERSION do
4
- it "should return a version string" do
5
- OpenStates::VERSION.class.should == String
4
+ it 'returns a version string' do
5
+ expect(OpenStates::VERSION.class).to eq(String)
6
6
  end
7
7
  end
8
-
9
-
@@ -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-debugger'
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.1.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-01-06 00:00:00.000000000 Z
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
@@ -1,9 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :rspec do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/openstates/(.+)\.rb$}) { |m| "spec/openstates/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
- end
9
-