govkit 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. data/README.markdown +2 -2
  2. data/Rakefile +4 -5
  3. data/VERSION +1 -1
  4. data/generators/govkit/templates/govkit.rb +4 -4
  5. data/govkit.gemspec +22 -7
  6. data/init.rb +4 -0
  7. data/lib/gov_kit/acts_as_citeable.rb +1 -1
  8. data/lib/gov_kit/configuration.rb +4 -4
  9. data/lib/gov_kit/follow_the_money.rb +30 -16
  10. data/lib/gov_kit/{fifty_states.rb → open_states.rb} +25 -13
  11. data/lib/gov_kit/railtie.rb +20 -0
  12. data/lib/gov_kit/resource.rb +17 -37
  13. data/lib/gov_kit/search_engines/google_news.rb +4 -4
  14. data/lib/gov_kit/search_engines/wikipedia.rb +21 -0
  15. data/lib/gov_kit/search_engines.rb +1 -0
  16. data/lib/gov_kit/vote_smart.rb +68 -4
  17. data/lib/gov_kit.rb +25 -24
  18. data/spec/fixtures/follow_the_money/business-page0.response +28 -0
  19. data/spec/fixtures/follow_the_money/business-page1.response +12 -0
  20. data/spec/fixtures/follow_the_money/contribution.response +12 -0
  21. data/spec/fixtures/follow_the_money/unauthorized.response +8 -0
  22. data/spec/fixtures/open_states/401.response +6 -0
  23. data/spec/fixtures/open_states/410.response +6 -0
  24. data/spec/fixtures/open_states/bill.response +240 -0
  25. data/spec/fixtures/open_states/bill_query.response +1990 -0
  26. data/spec/fixtures/open_states/legislator.response +34 -0
  27. data/spec/fixtures/open_states/legislator_query.response +144 -0
  28. data/spec/fixtures/open_states/state.response +60 -0
  29. data/spec/follow_the_money_spec.rb +57 -0
  30. data/spec/open_states_spec.rb +131 -0
  31. data/spec/spec_helper.rb +13 -0
  32. metadata +23 -14
  33. data/rails/init.rb +0 -3
  34. data/spec/fifty_states_spec.rb +0 -90
@@ -0,0 +1,34 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 22:02:59 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: close
6
+ Vary: Authorization
7
+
8
+ {
9
+ "first_name": "Dave",
10
+ "nimsp_candidate_id": 96237,
11
+ "middle_name": "",
12
+ "suffix": "",
13
+ "roles": [
14
+ {
15
+ "end_date": null,
16
+ "district": "1",
17
+ "contact_info": [],
18
+ "chamber": "upper",
19
+ "state": "ca",
20
+ "session": "20092010",
21
+ "committee": "",
22
+ "party": "Republican",
23
+ "votesmart_committee_id": null,
24
+ "type": "member",
25
+ "start_date": null
26
+ }
27
+ ],
28
+ "updated_at": "2010-03-27 22:07:46",
29
+ "sources": [],
30
+ "leg_id": 2462,
31
+ "last_name": "Cox",
32
+ "votesmart_id": 16766,
33
+ "full_name": "Cox, Dave"
34
+ }
@@ -0,0 +1,144 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 22:07:40 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: close
6
+ Vary: Authorization
7
+
8
+ [
9
+ {
10
+ "first_name": "Paul",
11
+ "nimsp_candidate_id": 96302,
12
+ "middle_name": "",
13
+ "suffix": "",
14
+ "roles": [
15
+ {
16
+ "end_date": null,
17
+ "district": "43",
18
+ "contact_info": [],
19
+ "chamber": "lower",
20
+ "state": "ca",
21
+ "session": "20092010",
22
+ "committee": "",
23
+ "party": "Democrat",
24
+ "votesmart_committee_id": null,
25
+ "type": "member",
26
+ "start_date": null
27
+ }
28
+ ],
29
+ "updated_at": "2010-03-27 22:06:53",
30
+ "sources": [],
31
+ "leg_id": 2560,
32
+ "last_name": "Krekorian",
33
+ "votesmart_id": null,
34
+ "full_name": "Krekorian, Paul"
35
+ },
36
+ {
37
+ "first_name": "Wesley",
38
+ "nimsp_candidate_id": 97762,
39
+ "middle_name": "",
40
+ "suffix": "",
41
+ "roles": [
42
+ {
43
+ "end_date": null,
44
+ "district": "1",
45
+ "contact_info": [],
46
+ "chamber": "lower",
47
+ "state": "ca",
48
+ "session": "20092010",
49
+ "committee": "",
50
+ "party": "Democrat",
51
+ "votesmart_committee_id": null,
52
+ "type": "member",
53
+ "start_date": null
54
+ }
55
+ ],
56
+ "updated_at": "2010-03-27 22:07:47",
57
+ "sources": [],
58
+ "leg_id": 2561,
59
+ "last_name": "Chesbro",
60
+ "votesmart_id": 16646,
61
+ "full_name": "Chesbro, Wesley"
62
+ },
63
+ {
64
+ "first_name": "Ted",
65
+ "nimsp_candidate_id": 96263,
66
+ "middle_name": "",
67
+ "suffix": "",
68
+ "roles": [
69
+ {
70
+ "end_date": null,
71
+ "district": "4",
72
+ "contact_info": [],
73
+ "chamber": "lower",
74
+ "state": "ca",
75
+ "session": "20092010",
76
+ "committee": "",
77
+ "party": "Republican",
78
+ "votesmart_committee_id": null,
79
+ "type": "member",
80
+ "start_date": null
81
+ }
82
+ ],
83
+ "updated_at": "2010-03-27 22:07:48",
84
+ "sources": [],
85
+ "leg_id": 2562,
86
+ "last_name": "Gaines",
87
+ "votesmart_id": 59841,
88
+ "full_name": "Gaines, Ted"
89
+ },
90
+ {
91
+ "first_name": "Jim",
92
+ "nimsp_candidate_id": 97994,
93
+ "middle_name": "",
94
+ "suffix": "",
95
+ "roles": [
96
+ {
97
+ "end_date": null,
98
+ "district": "2",
99
+ "contact_info": [],
100
+ "chamber": "lower",
101
+ "state": "ca",
102
+ "session": "20092010",
103
+ "committee": "",
104
+ "party": "Republican",
105
+ "votesmart_committee_id": null,
106
+ "type": "member",
107
+ "start_date": null
108
+ }
109
+ ],
110
+ "updated_at": "2010-03-27 22:07:49",
111
+ "sources": [],
112
+ "leg_id": 2563,
113
+ "last_name": "Nielsen",
114
+ "votesmart_id": 104331,
115
+ "full_name": "Nielsen, Jim"
116
+ },
117
+ {
118
+ "first_name": "Tom",
119
+ "nimsp_candidate_id": 97726,
120
+ "middle_name": "",
121
+ "suffix": "",
122
+ "roles": [
123
+ {
124
+ "end_date": null,
125
+ "district": "13",
126
+ "contact_info": [],
127
+ "chamber": "lower",
128
+ "state": "ca",
129
+ "session": "20092010",
130
+ "committee": "",
131
+ "party": "Democrat",
132
+ "votesmart_committee_id": null,
133
+ "type": "member",
134
+ "start_date": null
135
+ }
136
+ ],
137
+ "updated_at": "2010-03-27 22:07:47",
138
+ "sources": [],
139
+ "leg_id": 2564,
140
+ "last_name": "Ammiano",
141
+ "votesmart_id": 70419,
142
+ "full_name": "Ammiano, Tom"
143
+ }
144
+ ]
@@ -0,0 +1,60 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 21:44:48 GMT
4
+ Content-Type:
5
+ Connection: close
6
+ Vary: Authorization
7
+
8
+ {
9
+ "lower_chamber_name": "Assembly",
10
+ "lower_chamber_title": "Assemblymember",
11
+ "upper_chamber_title": "Senator",
12
+ "name": "California",
13
+ "sessions": [
14
+ {
15
+ "end_year": 2010,
16
+ "start_year": 2009,
17
+ "name": "20092010"
18
+ },
19
+ {
20
+ "end_year": 2010,
21
+ "start_year": 2009,
22
+ "name": "20092010 Special Session 1"
23
+ },
24
+ {
25
+ "end_year": 2010,
26
+ "start_year": 2009,
27
+ "name": "20092010 Special Session 2"
28
+ },
29
+ {
30
+ "end_year": 2010,
31
+ "start_year": 2009,
32
+ "name": "20092010 Special Session 3"
33
+ },
34
+ {
35
+ "end_year": 2010,
36
+ "start_year": 2009,
37
+ "name": "20092010 Special Session 4"
38
+ },
39
+ {
40
+ "end_year": 2010,
41
+ "start_year": 2009,
42
+ "name": "20092010 Special Session 5"
43
+ },
44
+ {
45
+ "end_year": 2010,
46
+ "start_year": 2009,
47
+ "name": "20092010 Special Session 6"
48
+ },
49
+ {
50
+ "end_year": 2010,
51
+ "start_year": 2009,
52
+ "name": "20092010 Special Session 7"
53
+ }
54
+ ],
55
+ "upper_chamber_term": 4,
56
+ "abbreviation": "ca",
57
+ "upper_chamber_name": "Senate",
58
+ "legislature_name": "California State Legislature",
59
+ "lower_chamber_term": 3
60
+ }
@@ -0,0 +1,57 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module GovKit::FollowTheMoney
4
+ describe GovKit::FollowTheMoney do
5
+
6
+ before(:all) do
7
+ base_uri = GovKit::FollowTheMoneyResource.base_uri.gsub(/\./, '\.')
8
+
9
+ urls = [
10
+ ['/base_level\.industries\.list\.php\?.*page=0', 'business-page0.response'],
11
+ ['/base_level\.industries\.list\.php\?.*page=1', 'business-page1.response'],
12
+ ['/candidates\.contributions\.php\?imsp_candidate_id=111933', 'contribution.response'],
13
+ ['/candidates\.contributions\.php\?imsp_candidate_id=0', 'unauthorized.response'],
14
+ ]
15
+
16
+ urls.each do |u|
17
+ FakeWeb.register_uri(:get, %r|#{base_uri}#{u[0]}|, :response => File.join(FIXTURES_DIR, 'follow_the_money', u[1]))
18
+ # puts "registered #{base_uri}#{u[0]}"
19
+ end
20
+ end
21
+
22
+ it "should have the base uri set properly" do
23
+ [Business, Contribution].each do |klass|
24
+ klass.base_uri.should == "http://api.followthemoney.org"
25
+ end
26
+ end
27
+
28
+ it "should raise NotAuthorizedError if the api key is not valid" do
29
+ lambda do
30
+ @contribution = Contribution.find(0)
31
+ end.should raise_error(GovKit::NotAuthorizedError)
32
+
33
+ @contribution.should be_nil
34
+ end
35
+
36
+ describe Business do
37
+ it "should get a list of industries" do
38
+ @businesses = Business.list
39
+ @businesses.should be_an_instance_of(Array)
40
+ @businesses.each do |b|
41
+ b.should be_an_instance_of(Business)
42
+ end
43
+ end
44
+ end
45
+
46
+ describe Contribution do
47
+ it "should get a list of campaign contributions for a given person" do
48
+ @contributions = Contribution.find(111933)
49
+ @contributions.should be_an_instance_of(Array)
50
+ @contributions.each do |c|
51
+ c.should be_an_instance_of(Contribution)
52
+ end
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,131 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module GovKit::OpenStates
4
+ describe GovKit::OpenStates do
5
+ before(:all) do
6
+ base_uri = GovKit::OpenStatesResource.base_uri.gsub(/\./, '\.')
7
+
8
+ urls = [
9
+ ['/ca/\?', 'state.response'],
10
+ ['/ca/20092010/lower/bills/AB667/', 'bill.response'],
11
+ ['/bills/search/\?', 'bill_query.response'],
12
+ ['/bills/latest/\?', 'bill_query.response'],
13
+ ['/legislators/2462/\?', 'legislator.response'],
14
+ ['/legislators/410/\?', '410.response'],
15
+ ['/legislators/401/\?', '401.response'],
16
+ ['/legislators/search/\?', 'legislator_query.response']
17
+ ]
18
+
19
+ urls.each do |u|
20
+ FakeWeb.register_uri(:get, %r|#{base_uri}#{u[0]}|, :response => File.join(FIXTURES_DIR, 'open_states', u[1]))
21
+ end
22
+ end
23
+
24
+ it "should have the base uri set properly" do
25
+ [State, Bill, Legislator].each do |klass|
26
+ klass.base_uri.should == "http://fiftystates-dev.sunlightlabs.com/api"
27
+ end
28
+ end
29
+
30
+ it "should raise NotAuthorizedError if the api key is not valid" do
31
+ # The Open States API returns a 401 Not Authorized if the API key is invalid.
32
+ lambda do
33
+ @legislator = Legislator.find(401)
34
+ end.should raise_error(GovKit::NotAuthorizedError)
35
+
36
+ @legislator.should be_nil
37
+ end
38
+
39
+ describe State do
40
+ context "#find_by_abbreviation" do
41
+ before do
42
+ end
43
+
44
+ it "should find a state by abbreviation" do
45
+ lambda do
46
+ @state = State.find_by_abbreviation('ca')
47
+ end.should_not raise_error
48
+
49
+ @state.should be_an_instance_of(State)
50
+ @state.name.should == "California"
51
+ @state.sessions.size.should == 8
52
+ end
53
+ end
54
+ end
55
+
56
+ describe Bill do
57
+ context "#find" do
58
+ it "should find a bill by stat abbreviation, session, chamber, bill_id" do
59
+ lambda do
60
+ @bill = Bill.find('ca', 20092010, 'lower', 'AB667')
61
+ end.should_not raise_error
62
+
63
+ @bill.should be_an_instance_of(Bill)
64
+ @bill.title.should include("An act to amend Section 1750.1 of the Business and Professions Code, and to amend Section 104830 of")
65
+ end
66
+ end
67
+
68
+ context "#search" do
69
+ it "should find bills by given criteria" do
70
+ @bills = Bill.search('cooperatives')
71
+
72
+ @bills.should be_an_instance_of(Array)
73
+ @bills.each do |b|
74
+ b.should be_an_instance_of(Bill)
75
+ end
76
+ @bills.collect(&:bill_id).should include("SB 921")
77
+ end
78
+ end
79
+
80
+ context "#latest" do
81
+ it "should get the latest bills by given criteria" do
82
+ lambda do
83
+ @latest = Bill.latest('2010-01-01','tx')
84
+ end.should_not raise_error
85
+
86
+ @latest.should be_an_instance_of(Array)
87
+ @latest.each do |b|
88
+ b.should be_an_instance_of(Bill)
89
+ end
90
+ @latest.collect(&:bill_id).should include("SB 2236")
91
+ end
92
+ end
93
+ end
94
+
95
+ describe Legislator do
96
+ context "#find" do
97
+ it "should find a specific legislator" do
98
+ lambda do
99
+ @legislator = Legislator.find(2462)
100
+ end.should_not raise_error
101
+
102
+ @legislator.should be_an_instance_of(Legislator)
103
+ @legislator.first_name.should == "Dave"
104
+ @legislator.last_name.should == "Cox"
105
+ end
106
+
107
+ it "should raise a GovKitError if the legislator is not found" do
108
+ lambda do
109
+ @legislator = Legislator.find(410)
110
+ end.should raise_error(GovKit::ResourceNotFoundError)
111
+
112
+ @legislator.should be_nil
113
+ end
114
+ end
115
+
116
+ context "#search" do
117
+ it "should get legislators by given criteria" do
118
+ lambda do
119
+ @legislators = Legislator.search(:state => 'ca')
120
+ end.should_not raise_error
121
+
122
+ @legislators.should be_an_instance_of(Array)
123
+ @legislators.each do |l|
124
+ l.should be_an_instance_of(Legislator)
125
+ end
126
+ end
127
+ end
128
+
129
+ end
130
+ end
131
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
+ require 'fakeweb'
4
+ require 'fakeweb_matcher'
3
5
  require File.dirname(__FILE__) + '/../lib/govkit'
4
6
 
5
7
  # prevent the use of `` in tests
@@ -23,3 +25,14 @@ module Kernel
23
25
  alias_method :rp, :p
24
26
  end
25
27
  end
28
+
29
+ FakeWeb.allow_net_connect = false
30
+
31
+ FIXTURES_DIR = File.join(File.dirname(__FILE__), 'fixtures')
32
+
33
+ GovKit.configure do |config|
34
+ config.openstates_apikey = 'YOUR_OPENSTATES_API_KEY'
35
+ config.votesmart_apikey = 'YOUR_VOTESMART_API_KEY'
36
+ config.ftm_apikey = 'YOUR_FTM_API_KEY'
37
+ config.opencongress_apikey = 'YOUR_OPENCONGRESS_API_KEY'
38
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govkit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 1
7
+ - 2
9
8
  - 0
10
- version: 0.1.0
9
+ version: 0.2.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Participatory Politics Foundation
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-06-10 00:00:00 -07:00
19
+ date: 2010-08-31 00:00:00 -07:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -28,7 +27,6 @@ dependencies:
28
27
  requirements:
29
28
  - - ">="
30
29
  - !ruby/object:Gem::Version
31
- hash: 15
32
30
  segments:
33
31
  - 0
34
32
  - 5
@@ -44,7 +42,6 @@ dependencies:
44
42
  requirements:
45
43
  - - ">="
46
44
  - !ruby/object:Gem::Version
47
- hash: 1
48
45
  segments:
49
46
  - 1
50
47
  - 4
@@ -60,7 +57,6 @@ dependencies:
60
57
  requirements:
61
58
  - - ">="
62
59
  - !ruby/object:Gem::Version
63
- hash: 59
64
60
  segments:
65
61
  - 0
66
62
  - 8
@@ -68,7 +64,7 @@ dependencies:
68
64
  version: 0.8.2
69
65
  type: :runtime
70
66
  version_requirements: *id003
71
- description: Govkit lets you quickly get encapsulated Ruby objects for common open government APIs. We're starting with Sunlight's Fifty States API and the Project Vote Smart API.
67
+ description: Govkit lets you quickly get encapsulated Ruby objects for common open government APIs. We're starting with Sunlight's Open States API and the Project Vote Smart API.
72
68
  email: carl@ppolitics.org
73
69
  executables: []
74
70
 
@@ -88,10 +84,10 @@ files:
88
84
  - generators/govkit/govkit_generator.rb
89
85
  - generators/govkit/templates/govkit.rb
90
86
  - govkit.gemspec
87
+ - init.rb
91
88
  - lib/gov_kit.rb
92
89
  - lib/gov_kit/acts_as_citeable.rb
93
90
  - lib/gov_kit/configuration.rb
94
- - lib/gov_kit/fifty_states.rb
95
91
  - lib/gov_kit/follow_the_money.rb
96
92
  - lib/gov_kit/open_congress.rb
97
93
  - lib/gov_kit/open_congress/bill.rb
@@ -102,15 +98,29 @@ files:
102
98
  - lib/gov_kit/open_congress/roll_call.rb
103
99
  - lib/gov_kit/open_congress/roll_call_comparison.rb
104
100
  - lib/gov_kit/open_congress/voting_comparison.rb
101
+ - lib/gov_kit/open_states.rb
102
+ - lib/gov_kit/railtie.rb
105
103
  - lib/gov_kit/resource.rb
106
104
  - lib/gov_kit/search_engines.rb
107
105
  - lib/gov_kit/search_engines/google_blog.rb
108
106
  - lib/gov_kit/search_engines/google_news.rb
109
107
  - lib/gov_kit/search_engines/technorati.rb
108
+ - lib/gov_kit/search_engines/wikipedia.rb
110
109
  - lib/gov_kit/vote_smart.rb
111
110
  - lib/govkit.rb
112
- - rails/init.rb
113
- - spec/fifty_states_spec.rb
111
+ - spec/fixtures/follow_the_money/business-page0.response
112
+ - spec/fixtures/follow_the_money/business-page1.response
113
+ - spec/fixtures/follow_the_money/contribution.response
114
+ - spec/fixtures/follow_the_money/unauthorized.response
115
+ - spec/fixtures/open_states/401.response
116
+ - spec/fixtures/open_states/410.response
117
+ - spec/fixtures/open_states/bill.response
118
+ - spec/fixtures/open_states/bill_query.response
119
+ - spec/fixtures/open_states/legislator.response
120
+ - spec/fixtures/open_states/legislator_query.response
121
+ - spec/fixtures/open_states/state.response
122
+ - spec/follow_the_money_spec.rb
123
+ - spec/open_states_spec.rb
114
124
  - spec/spec.opts
115
125
  - spec/spec_helper.rb
116
126
  has_rdoc: true
@@ -127,7 +137,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
137
  requirements:
128
138
  - - ">="
129
139
  - !ruby/object:Gem::Version
130
- hash: 3
131
140
  segments:
132
141
  - 0
133
142
  version: "0"
@@ -136,7 +145,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
145
  requirements:
137
146
  - - ">="
138
147
  - !ruby/object:Gem::Version
139
- hash: 3
140
148
  segments:
141
149
  - 0
142
150
  version: "0"
@@ -148,5 +156,6 @@ signing_key:
148
156
  specification_version: 3
149
157
  summary: Simple access to open government APIs around the web
150
158
  test_files:
151
- - spec/fifty_states_spec.rb
159
+ - spec/follow_the_money_spec.rb
160
+ - spec/open_states_spec.rb
152
161
  - spec/spec_helper.rb
data/rails/init.rb DELETED
@@ -1,3 +0,0 @@
1
- # Include hook code here
2
- require File.join(File.dirname(__FILE__), *%w[.. lib govkit])
3
- ActiveRecord::Base.send(:include, GovKit::ActsAsCiteable)
@@ -1,90 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- #TODO: Mock http requests, rather than making an actual call to the api
4
-
5
- module GovKit::FiftyStates
6
- describe GovKit::FiftyStates do
7
- it "should have the base uri set properly" do
8
- [State, Bill, Legislator].each do |klass|
9
- klass.base_uri.should == "http://fiftystates-dev.sunlightlabs.com/api"
10
- end
11
- end
12
- end
13
-
14
- describe State do
15
- context "#find_by_abbreviation" do
16
- before do
17
- #TODO: Mock request for State
18
- end
19
- it "should find a state by abbreviation" do
20
- lambda do
21
- @state = State.find_by_abbreviation('ca')
22
- end.should_not raise_error
23
-
24
- @state.should_not be_nil
25
- @state.name.should == "California"
26
- end
27
- end
28
- end
29
-
30
- describe Bill do
31
- context "#find" do
32
- before do
33
- #TODO: Mock request for Bill
34
- end
35
-
36
- it "should find a bill by stat abbreviation, session, chamber, bill_id" do
37
- lambda do
38
- @bill = Bill.find('ca', 20092010, 'lower', 'AB667')
39
- end.should_not raise_error
40
-
41
- @bill.should_not be_nil
42
- @bill.title.should include("An act to amend Section 1750.1 of the Business and Professions Code, and to amend Section 104830 of")
43
- end
44
- end
45
-
46
- context "#search" do
47
- it "should find bills by given criteria" do
48
- @bills = Bill.search('agriculture')
49
-
50
- @bills.should_not be_nil
51
- @bills.collect(&:bill_id).should include("S 0438")
52
- end
53
- end
54
-
55
- context "#latest" do
56
- it "should get the latest bills by given criteria" do
57
- lambda do
58
- @latest = Bill.latest('2010-01-01','sd')
59
- end.should_not raise_error
60
-
61
- @latest.collect(&:bill_id).should include("SB 7")
62
- end
63
- end
64
- end
65
-
66
- describe Legislator do
67
- before do
68
- #TODO: Mock request for legislator
69
- end
70
- context "#find" do
71
- it "should get the latest bill" do
72
- lambda do
73
- @legislator = Legislator.find(2462)
74
- end.should_not raise_error
75
-
76
- @legislator.first_name.should == "Dave"
77
- @legislator.last_name.should == "Cox"
78
- end
79
- end
80
- context "#search" do
81
- it "should get legislators by given criteria" do
82
- lambda do
83
- @legislators = Legislator.search(:state => 'ca')
84
- end.should_not raise_error
85
-
86
- @legislators.should_not be_nil
87
- end
88
- end
89
- end
90
- end