congress 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
+ language: ruby
1
2
  rvm:
3
+ - jruby-18mode
4
+ - jruby-19mode
5
+ - rbx-18mode
6
+ - rbx-19mode
2
7
  - 1.8.7
3
8
  - 1.9.2
4
9
  - 1.9.3
5
- - jruby
6
- - rbx
7
- - rbx-2.0
8
- - ree
10
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,7 +1,21 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'rake'
4
+
3
5
  platforms :jruby do
4
6
  gem 'jruby-openssl', '~> 0.7'
5
7
  end
6
8
 
9
+ group :development do
10
+ gem 'json', :platforms => :ruby_18
11
+ gem 'kramdown'
12
+ gem 'simplecov'
13
+ gem 'yard'
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec'
18
+ gem 'webmock'
19
+ end
20
+
7
21
  gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011, Code for America
1
+ Copyright (c) 2011-2013, Code for America
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
data/README.md CHANGED
@@ -1,49 +1,60 @@
1
1
  # Ruby wrapper for the Real-Time Congress API
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/congress.png)][gem]
4
+ [![Build Status](https://secure.travis-ci.org/codeforamerica/congress.png)][travis]
5
+ [![Dependency Status](https://gemnasium.com/codeforamerica/congress.png?travis)][gemnasium]
6
+ [![Code Climate](https://codeclimate.com/github/codeforamerica/congress.png)][codeclimate]
7
+ [gem]: https://rubygems.org/gems/congress
8
+ [travis]: http://travis-ci.org/codeforamerica/congress
9
+ [gemnasium]: https://gemnasium.com/codeforamerica/congress
10
+ [codeclimate]: https://codeclimate.com/github/codeforamerica/congress
11
+
2
12
  The Real-Time Congress (RTC) API is a RESTful API over the artifacts of
3
13
  Congress, in as close to real-time as possible.
4
14
 
5
- ## <a name="installation">Installation</a>
15
+ ## Installation
6
16
  gem install congress
7
17
 
8
- ## <a name="documentation">Documentation</a>
9
- [http://rdoc.info/gems/congress](http://rdoc.info/gems/congress)
18
+ ## Documentation
19
+ [http://rdoc.info/gems/congress][documentation]
20
+ [documentation]: http://rdoc.info/gems/congress
10
21
 
11
- ## <a name="ci">Continuous Integration</a>
12
- [![Build Status](https://secure.travis-ci.org/codeforamerica/congress.png)](http://travis-ci.org/codeforamerica/congress)
22
+ ## Usage Examples
23
+ ```ruby
24
+ require 'rubygems'
25
+ require 'congress'
13
26
 
14
- ## <a name="examples">Usage Examples</a>
15
- require 'rubygems'
16
- require 'congress'
27
+ # An API key is required
28
+ # You can obtain one from http://services.sunlightlabs.com/accounts/register/
29
+ Congress.key = YOUR_RTC_API_KEY
17
30
 
18
- # An API key is required
19
- # You can obtain one from http://services.sunlightlabs.com/accounts/register/
20
- Congress.key = YOUR_RTC_API_KEY
31
+ # Fetch bills introduced bills and resolutions in Congress
32
+ puts Congress.bills
21
33
 
22
- # Fetch bills introduced bills and resolutions in Congress
23
- puts Congress.bills
34
+ # Fetch votes taken in Congress
35
+ puts Congress.votes
24
36
 
25
- # Fetch votes taken in Congress
26
- puts Congress.votes
37
+ # Fetch amendments to bills and resolutions offered in Congress
38
+ puts Congress.amendments
27
39
 
28
- # Fetch amendments to bills and resolutions offered in Congress
29
- puts Congress.amendments
40
+ # Fetch videos from the U.S. House of Representatives and from the White House
41
+ puts Congress.videos
30
42
 
31
- # Fetch videos from the U.S. House of Representatives and from the White House
32
- puts Congress.videos
43
+ # Fetch updates from the floor of each chamber of Congress
44
+ puts Congress.floor_updates
33
45
 
34
- # Fetch updates from the floor of each chamber of Congress
35
- puts Congress.floor_updates
46
+ # Fetch upcoming scheduled committee hearings in the House and Senate
47
+ puts Congress.committee_hearings
36
48
 
37
- # Fetch upcoming scheduled committee hearings in the House and Senate
38
- puts Congress.committee_hearings
49
+ # Fetch links to various kinds of documents produced by agencies within Congress
50
+ puts Congress.documents
51
+ ```
39
52
 
40
- # Fetch links to various kinds of documents produced by agencies within Congress
41
- puts Congress.documents
53
+ ## Contributing
54
+ In the spirit of [free software][free-sw], **everyone** is encouraged to help improve
55
+ this project.
42
56
 
43
- ## <a name="contributing">Contributing</a>
44
- In the spirit of [free
45
- software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is
46
- encouraged to help improve this project.
57
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
47
58
 
48
59
  Here are some ways *you* can contribute:
49
60
 
@@ -55,45 +66,51 @@ Here are some ways *you* can contribute:
55
66
  * by writing code (**no patch is too small**: fix typos, add comments, clean up
56
67
  inconsistent whitespace)
57
68
  * by refactoring code
58
- * by closing [issues](https://github.com/codeforamerica/congress/issues)
69
+ * by fixing [issues][]
59
70
  * by reviewing patches
60
71
 
61
- ## <a name="issues">Submitting an Issue</a>
62
- We use the [GitHub issue tracker](https://github.com/codeforamerica/congress/issues) to
63
- track bugs and features. Before submitting a bug report or feature request,
64
- check to make sure it hasn't already been submitted. You can indicate support
65
- for an existing issuse by voting it up. When submitting a bug report, please
66
- include a [Gist](https://gist.github.com/) that includes a stack trace and any
67
- details that may be necessary to reproduce the bug, including your gem version,
68
- Ruby version, and operating system. Ideally, a bug report should include a pull
69
- request with failing specs.
70
-
71
- ## <a name="pulls">Submitting a Pull Request</a>
72
- 1. Fork the project.
73
- 2. Create a topic branch.
74
- 3. Implement your feature or bug fix.
75
- 4. Add documentation for your feature or bug fix.
76
- 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100%
77
- documented, go back to step 4.
78
- 6. Add specs for your feature or bug fix.
79
- 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go
80
- back to step 6.
81
- 8. Commit and push your changes.
82
- 9. Submit a pull request. Please do not include changes to the gemspec,
83
- version, or history file. (If you want to create your own version for some
84
- reason, please do so in a separate commit.)
85
-
86
- ## <a name="rubies">Supported Rubies</a>
87
- This library aims to support and is [tested
88
- against](http://travis-ci.org/codeforamerica/congress) the following Ruby
72
+ [issues]: https://github.com/codeforamerica/congress/issues
73
+
74
+ ## Submitting an Issue
75
+ We use the [GitHub issue tracker][issues] to track bugs and features. Before
76
+ submitting a bug report or feature request, check to make sure it hasn't
77
+ already been submitted. When submitting a bug report, please include a [Gist][]
78
+ that includes a stack trace and any details that may be necessary to reproduce
79
+ the bug, including your gem version, Ruby version, and operating system.
80
+ Ideally, a bug report should include a pull request with failing specs.
81
+
82
+ ## Submitting a Pull Request
83
+ 1. [Fork the repository.][fork]
84
+ 2. [Create a topic branch.][branch]
85
+ 3. Add specs for your unimplemented feature or bug fix.
86
+ 4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
87
+ 5. Implement your feature or bug fix.
88
+ 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
89
+ 7. Run `open coverage/index.html`. If your changes are not completely covered
90
+ by your tests, return to step 3.
91
+ 8. Add documentation for your feature or bug fix.
92
+ 9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
93
+ back to step 8.
94
+ 10. Add, commit, and push your changes.
95
+ 11. [Submit a pull request.][pr]
96
+
97
+ [fork]: http://help.github.com/fork-a-repo/
98
+ [branch]: http://learn.github.com/p/branching.html
99
+ [pr]: http://help.github.com/send-pull-requests/
100
+
101
+ ## Supported Rubies
102
+ This library aims to support and is [tested against][travis] the following Ruby
89
103
  implementations:
90
104
 
91
105
  * Ruby 1.8.7
92
- * Ruby 1.9.1
93
106
  * Ruby 1.9.2
94
- * [JRuby](http://www.jruby.org/)
95
- * [Rubinius](http://rubini.us/)
96
- * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
107
+ * Ruby 1.9.3
108
+ * Ruby 2.0.0
109
+ * [JRuby][]
110
+ * [Rubinius][]
111
+
112
+ [jruby]: http://www.jruby.org/
113
+ [rubinius]: http://rubini.us/
97
114
 
98
115
  If something doesn't work on one of these interpreters, it should be considered
99
116
  a bug.
@@ -109,8 +126,7 @@ implementation, you will be personally responsible for providing patches in a
109
126
  timely fashion. If critical issues for a particular implementation exist at the
110
127
  time of a major release, support for that Ruby version may be dropped.
111
128
 
112
- ## <a name="copyright">Copyright</a>
113
- Copyright (c) 2011, Code for America. All rights reserved.
114
- See [LICENSE](https://github.com/codeforamerica/congress/blob/master/LICENSE.md) for details.
129
+ ## Copyright
130
+ Copyright (c) 2011-2013, Code for America. See [LICENSE][] for details.
115
131
 
116
- [![Code for America Tracker](http://stats.codeforamerica.org/codeforamerica/congress.png)](http://stats.codeforamerica.org/projects/congress)
132
+ [license]: https://github.com/codeforamerica/congress/blob/master/LICENSE.md
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env rake
2
-
3
1
  require 'bundler'
4
2
  Bundler::GemHelper.install_tasks
5
3
 
data/congress.gemspec CHANGED
@@ -2,18 +2,11 @@
2
2
  require File.expand_path('../lib/congress/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_dependency 'faraday', '~> 0.7'
6
- gem.add_dependency 'faraday_middleware', '~> 0.7'
7
- gem.add_dependency 'hashie', '~> 1.1'
8
- gem.add_dependency 'multi_json', '~> 1.0'
9
- gem.add_dependency 'rash', '~> 0.3'
10
- gem.add_development_dependency 'json'
11
- gem.add_development_dependency 'rake'
12
- gem.add_development_dependency 'rdiscount'
13
- gem.add_development_dependency 'rspec'
14
- gem.add_development_dependency 'simplecov'
15
- gem.add_development_dependency 'webmock'
16
- gem.add_development_dependency 'yard'
5
+ gem.add_dependency 'faraday', '~> 0.8.7'
6
+ gem.add_dependency 'faraday_middleware', '~> 0.9.0'
7
+ gem.add_dependency 'hashie', '~> 2.0'
8
+ gem.add_dependency 'rash', '~> 0.4'
9
+ gem.add_development_dependency 'bundler', '~> 1.0'
17
10
  gem.author = "Erik Michaels-Ober"
18
11
  gem.description = %q{Ruby wrapper for the Real-Time Congress API. The Real-Time Congress API is a RESTful API over the artifacts of Congress, in as close to real-time as possible.}
19
12
  gem.email = 'sferik@gmail.com'
@@ -3,77 +3,127 @@ require 'congress/request'
3
3
 
4
4
  module Congress
5
5
  class Client
6
- include Congress::Connection
7
- include Congress::Request
6
+ include Connection
7
+ include Request
8
8
 
9
- # Fetch bills introduced bills and resolutions in Congress
9
+ # Current legislators' names, IDs, biography, and social media.
10
10
  #
11
11
  # @return [Hashie::Rash]
12
12
  # @example
13
13
  # Congress.key = YOUR_RTC_API_KEY
14
- # Congress.bills
15
- def bills(options={})
16
- get('/api/v1/bills.json', options.merge(api_key))
14
+ # Congress.legislators
15
+ def legislators(options={})
16
+ get('/legislators', options.merge(api_key))
17
17
  end
18
18
 
19
- # Fetch votes taken in Congress
19
+ # Find representatives and senators for a latitude/longitude or zip.
20
20
  #
21
21
  # @return [Hashie::Rash]
22
22
  # @example
23
23
  # Congress.key = YOUR_RTC_API_KEY
24
- # Congress.votes
25
- def votes(options={})
26
- get('/api/v1/votes.json', options.merge(api_key))
24
+ # Congress.legislators_locate(94107)
25
+ # Congress.legislators_locate(37.775, -122.418)
26
+ def legislators_locate(*args)
27
+ options = args.last.is_a?(::Hash) ? args.pop : {}
28
+ if args.size == 1
29
+ options[:zip] = args.pop
30
+ elsif args.size == 2
31
+ options[:longitude] = args.pop
32
+ options[:latitude] = args.pop
33
+ else
34
+ raise ArgumentError, "Must pass a latitude/longitude or zip"
35
+ end
36
+ get('/legislators/locate', options.merge(api_key))
37
+ end
38
+
39
+ # Find congressional districts for a latitude/longitude or zip.
40
+ #
41
+ # @return [Hashie::Rash]
42
+ # @example
43
+ # Congress.key = YOUR_RTC_API_KEY
44
+ # Congress.districts_locate(94107)
45
+ # Congress.districts_locate(37.775, -122.418)
46
+ def districts_locate(*args)
47
+ options = args.last.is_a?(::Hash) ? args.pop : {}
48
+ if args.size == 1
49
+ options[:zip] = args.pop
50
+ elsif args.size == 2
51
+ options[:longitude] = args.pop
52
+ options[:latitude] = args.pop
53
+ else
54
+ raise ArgumentError, "Must pass a latitude/longitude or zip"
55
+ end
56
+ get('/districts/locate', options.merge(api_key))
57
+ end
58
+
59
+ # Current committees, subcommittees, and their membership.
60
+ #
61
+ # @return [Hashie::Rash]
62
+ # @example
63
+ # Congress.key = YOUR_RTC_API_KEY
64
+ # Congress.committees
65
+ def committees(options={})
66
+ get('/committees', options.merge(api_key))
27
67
  end
28
68
 
29
- # Fetch amendments to bills and resolutions offered in Congress
69
+ # Legislation in the House and Senate, back to 2009. Updated daily.
30
70
  #
31
71
  # @return [Hashie::Rash]
32
72
  # @example
33
73
  # Congress.key = YOUR_RTC_API_KEY
34
- # Congress.amendments
35
- def amendments(options={})
36
- get('/api/v1/amendments.json', options.merge(api_key))
74
+ # Congress.bills
75
+ def bills(options={})
76
+ get('/bills', options.merge(api_key))
37
77
  end
38
78
 
39
- # Fetch videos from the U.S. House of Representatives and from the White House
79
+ # ull text search over legislation.
40
80
  #
41
81
  # @return [Hashie::Rash]
42
82
  # @example
43
83
  # Congress.key = YOUR_RTC_API_KEY
44
- # Congress.videos
45
- def videos(options={})
46
- get('/api/v1/videos.json', options.merge(api_key))
84
+ # Congress.bills_search
85
+ def bills_search(options={})
86
+ get('/bills/search', options.merge(api_key))
87
+ end
88
+
89
+ # Roll call votes in Congress, back to 2009. Updated within minutes of votes.
90
+ #
91
+ # @return [Hashie::Rash]
92
+ # @example
93
+ # Congress.key = YOUR_RTC_API_KEY
94
+ # Congress.votes
95
+ def votes(options={})
96
+ get('/votes', options.merge(api_key))
47
97
  end
48
98
 
49
- # Fetch updates from the floor of each chamber of Congress
99
+ # To-the-minute updates from the floor of the House and Senate.
50
100
  #
51
101
  # @return [Hashie::Rash]
52
102
  # @example
53
103
  # Congress.key = YOUR_RTC_API_KEY
54
104
  # Congress.floor_updates
55
105
  def floor_updates(options={})
56
- get('/api/v1/floor_updates.json', options.merge(api_key))
106
+ get('/floor_updates', options.merge(api_key))
57
107
  end
58
108
 
59
- # Fetch upcoming scheduled committee hearings in the House and Senate
109
+ # Committee hearings in Congress. Updated as hearings are announced.
60
110
  #
61
111
  # @return [Hashie::Rash]
62
112
  # @example
63
113
  # Congress.key = YOUR_RTC_API_KEY
64
- # Congress.committee_hearings
65
- def committee_hearings(options={})
66
- get('/api/v1/committee_hearings.json', options.merge(api_key))
114
+ # Congress.hearings
115
+ def hearings(options={})
116
+ get('/hearings', options.merge(api_key))
67
117
  end
68
118
 
69
- # Fetch links to various kinds of documents produced by agencies within Congress
119
+ # Bills scheduled for debate in the future, as announced by party leadership.
70
120
  #
71
121
  # @return [Hashie::Rash]
72
122
  # @example
73
123
  # Congress.key = YOUR_RTC_API_KEY
74
- # Congress.documents
75
- def documents(options={})
76
- get('/api/v1/documents.json', options.merge(api_key))
124
+ # Congress.upcoming_bills
125
+ def upcoming_bills(options={})
126
+ get('/upcoming_bills', options.merge(api_key))
77
127
  end
78
128
 
79
129
  private
@@ -5,7 +5,7 @@ module Congress
5
5
  private
6
6
 
7
7
  def connection
8
- Faraday.new(:url => 'http://api.realtimecongress.org') do |connection|
8
+ Faraday.new(:url => 'http://congress.api.sunlightfoundation.com') do |connection|
9
9
  connection.use Faraday::Request::UrlEncoded
10
10
  connection.use Faraday::Response::RaiseError
11
11
  connection.use Faraday::Response::Rashify
@@ -1,3 +1,3 @@
1
1
  module Congress
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -8,108 +8,187 @@ describe Congress::Client do
8
8
  end
9
9
  end
10
10
 
11
- describe '#bills' do
11
+ describe '#legislators' do
12
12
  before do
13
- stub_get('/api/v1/bills.json?apikey=abc123').
14
- to_return(:status => 200, :body => fixture('bills.json'))
13
+ stub_get('/legislators?apikey=abc123').
14
+ to_return(:status => 200, :body => fixture('legislators.json'))
15
15
  end
16
-
17
- it "should fetch bills introduced bills and resolutions in Congress" do
18
- bills = @client.bills
19
- a_get('/api/v1/bills.json?apikey=abc123').
16
+ it "fetches current legislators' names, IDs, biography, and social media" do
17
+ legislators = @client.legislators
18
+ a_get('/legislators?apikey=abc123').
20
19
  should have_been_made
21
- bills['count'].should == 17836
22
- bills['bills'].first.bill_id.should == "hres314-112"
20
+ legislators['count'].should == 539
21
+ legislators['results'].first.bioguide_id.should == "K000385"
23
22
  end
24
23
  end
25
24
 
26
- describe '#votes' do
27
- before do
28
- stub_get('/api/v1/votes.json?apikey=abc123').
29
- to_return(:status => 200, :body => fixture('votes.json'))
25
+ describe '#legislators_locate' do
26
+ context "with a zip code passed" do
27
+ before do
28
+ stub_get('/legislators/locate?apikey=abc123&zip=94107').
29
+ to_return(:status => 200, :body => fixture('legislators_locate.json'))
30
+ end
31
+ it "fetches representatives and senators for a latitude/longitude or zip" do
32
+ legislators_locate = @client.legislators_locate(94107)
33
+ a_get('/legislators/locate?apikey=abc123&zip=94107').
34
+ should have_been_made
35
+ legislators_locate['count'].should == 3
36
+ legislators_locate['results'].first.bioguide_id.should == "P000197"
37
+ end
38
+ end
39
+ context "with a latitude and longitude passed" do
40
+ before do
41
+ stub_get('/legislators/locate?apikey=abc123&latitude=37.775&longitude=-122.418').
42
+ to_return(:status => 200, :body => fixture('legislators_locate.json'))
43
+ end
44
+ it "fetches representatives and senators for a latitude/longitude or zip" do
45
+ legislators_locate = @client.legislators_locate(37.775, -122.418)
46
+ a_get('/legislators/locate?apikey=abc123&latitude=37.775&longitude=-122.418').
47
+ should have_been_made
48
+ legislators_locate['count'].should == 3
49
+ legislators_locate['results'].first.bioguide_id.should == "P000197"
50
+ end
51
+ end
52
+ context "with no arguments passed" do
53
+ it "raises an argument error" do
54
+ lambda {
55
+ @client.legislators_locate
56
+ }.should raise_error ArgumentError
57
+ end
30
58
  end
59
+ end
31
60
 
32
- it "should fetch votes taken in Congress" do
33
- votes = @client.votes
34
- a_get('/api/v1/votes.json?apikey=abc123').
35
- should have_been_made
36
- votes['count'].should == 5103
37
- votes['votes'].first.roll_id.should == "s91-2011"
61
+ describe '#districts_locate' do
62
+ context "with a zip code passed" do
63
+ before do
64
+ stub_get('/districts/locate?apikey=abc123&zip=94107').
65
+ to_return(:status => 200, :body => fixture('districts_locate.json'))
66
+ end
67
+ it "fetches congressional districts for a latitude/longitude or zip" do
68
+ districts_locate = @client.districts_locate(94107)
69
+ a_get('/districts/locate?apikey=abc123&zip=94107').
70
+ should have_been_made
71
+ districts_locate['count'].should == 1
72
+ districts_locate['results'].first.district.should == 12
73
+ end
74
+ end
75
+ context "with a latitude and longitude passed" do
76
+ before do
77
+ stub_get('/districts/locate?apikey=abc123&latitude=37.775&longitude=-122.418').
78
+ to_return(:status => 200, :body => fixture('districts_locate.json'))
79
+ end
80
+ it "fetches congressional districts for a latitude/longitude or zip" do
81
+ districts_locate = @client.districts_locate(37.775, -122.418)
82
+ a_get('/districts/locate?apikey=abc123&latitude=37.775&longitude=-122.418').
83
+ should have_been_made
84
+ districts_locate['count'].should == 1
85
+ districts_locate['results'].first.district.should == 12
86
+ end
87
+ end
88
+ context "with no arguments passed" do
89
+ it "raises an argument error" do
90
+ lambda {
91
+ @client.districts_locate
92
+ }.should raise_error ArgumentError
93
+ end
38
94
  end
39
95
  end
40
96
 
41
- describe '#amendments' do
97
+ describe '#committees' do
42
98
  before do
43
- stub_get('/api/v1/amendments.json?apikey=abc123').
44
- to_return(:status => 200, :body => fixture('amendments.json'))
99
+ stub_get('/committees?apikey=abc123').
100
+ to_return(:status => 200, :body => fixture('committees.json'))
101
+ end
102
+ it "fetches legislation in the House and Senate" do
103
+ committees = @client.committees
104
+ a_get('/committees?apikey=abc123').
105
+ should have_been_made
106
+ committees['count'].should == 120
107
+ committees['results'].first.chamber.should == "senate"
45
108
  end
109
+ end
46
110
 
47
- it "should fetch amendments to bills and resolutions offered in Congress" do
48
- amendments = @client.amendments
49
- a_get('/api/v1/amendments.json?apikey=abc123').
111
+ describe '#bills' do
112
+ before do
113
+ stub_get('/bills?apikey=abc123').
114
+ to_return(:status => 200, :body => fixture('bills.json'))
115
+ end
116
+ it "fetches legislation in the House and Senate" do
117
+ bills = @client.bills
118
+ a_get('/bills?apikey=abc123').
50
119
  should have_been_made
51
- amendments['count'].should == 6606
52
- amendments['amendments'].first.bill_id.should == "s679-112"
120
+ bills['count'].should == 28614
121
+ bills['results'].first.bill_id.should == "s730-113"
53
122
  end
54
123
  end
55
124
 
56
- describe '#videos' do
125
+ describe '#bills_search' do
57
126
  before do
58
- stub_get('/api/v1/videos.json?apikey=abc123').
59
- to_return(:status => 200, :body => fixture('videos.json'))
127
+ stub_get('/bills/search?apikey=abc123').
128
+ to_return(:status => 200, :body => fixture('bills_search.json'))
129
+ end
130
+ it "fetches legislation" do
131
+ bills_search = @client.bills_search
132
+ a_get('/bills/search?apikey=abc123').
133
+ should have_been_made
134
+ bills_search['count'].should == 28614
135
+ bills_search['results'].first.bill_type.should == "hr"
60
136
  end
137
+ end
61
138
 
62
- it "should fetch videos from the U.S. House of Representatives and from the White House" do
63
- videos = @client.videos
64
- a_get('/api/v1/videos.json?apikey=abc123').
139
+ describe '#votes' do
140
+ before do
141
+ stub_get('/votes?apikey=abc123').
142
+ to_return(:status => 200, :body => fixture('votes.json'))
143
+ end
144
+ it "fetches roll call votes in Congress" do
145
+ votes = @client.votes
146
+ a_get('/votes?apikey=abc123').
65
147
  should have_been_made
66
- videos['count'].should == 1034
67
- videos['videos'].first.video_id.should == "whitehouse-1308389400-weekly-address-celebrating-fathers"
148
+ votes['count'].should == 4647
149
+ votes['results'].first.roll_id.should == "h106-2013"
68
150
  end
69
151
  end
70
152
 
71
153
  describe '#floor_updates' do
72
154
  before do
73
- stub_get('/api/v1/floor_updates.json?apikey=abc123').
155
+ stub_get('/floor_updates?apikey=abc123').
74
156
  to_return(:status => 200, :body => fixture('floor_updates.json'))
75
157
  end
76
-
77
- it "should fetch updates from the floor of each chamber of Congress" do
158
+ it "fetches to-the-minute updates from the floor of the House and Senate" do
78
159
  floor_updates = @client.floor_updates
79
- a_get('/api/v1/floor_updates.json?apikey=abc123').
160
+ a_get('/floor_updates?apikey=abc123').
80
161
  should have_been_made
81
- floor_updates['count'].should == 2183
82
- floor_updates['floor_updates'].first.chamber.should == "senate"
162
+ floor_updates['count'].should == 3066
163
+ floor_updates['results'].first.chamber.should == "senate"
83
164
  end
84
165
  end
85
166
 
86
- describe '#committee_hearings' do
167
+ describe '#hearings' do
87
168
  before do
88
- stub_get('/api/v1/committee_hearings.json?apikey=abc123').
89
- to_return(:status => 200, :body => fixture('committee_hearings.json'))
169
+ stub_get('/hearings?apikey=abc123').
170
+ to_return(:status => 200, :body => fixture('hearings.json'))
90
171
  end
91
-
92
- it "should fetch upcoming scheduled committee hearings in the House and Senate" do
93
- committee_hearings = @client.committee_hearings
94
- a_get('/api/v1/committee_hearings.json?apikey=abc123').
172
+ it "fetches committee hearings in Congress" do
173
+ hearings = @client.hearings
174
+ a_get('/hearings?apikey=abc123').
95
175
  should have_been_made
96
- committee_hearings['count'].should == 482
97
- committee_hearings['committee_hearings'].first.committee_id.should == "SSVA"
176
+ hearings['count'].should == 1279
177
+ hearings['results'].first.committee_id.should == "SSFR"
98
178
  end
99
179
  end
100
180
 
101
- describe '#documents' do
181
+ describe '#upcoming_bills' do
102
182
  before do
103
- stub_get('/api/v1/documents.json?apikey=abc123').
104
- to_return(:status => 200, :body => fixture('documents.json'))
183
+ stub_get('/upcoming_bills?apikey=abc123').
184
+ to_return(:status => 200, :body => fixture('upcoming_bills.json'))
105
185
  end
106
-
107
- it "should fetch links to various kinds of documents produced by agencies within Congress" do
108
- documents = @client.documents
109
- a_get('/api/v1/documents.json?apikey=abc123').
186
+ it "fetches committee hearings in Congress" do
187
+ upcoming_bills = @client.upcoming_bills
188
+ a_get('/upcoming_bills?apikey=abc123').
110
189
  should have_been_made
111
- documents['count'].should == 124
112
- documents['documents'].first.document_type.should == "whip_notice"
190
+ upcoming_bills['count'].should == 9
191
+ upcoming_bills['results'].first.bill_id.should == "s3457-113"
113
192
  end
114
193
  end
115
194