statement 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statement/scraper.rb +71 -11
- data/lib/statement/version.rb +1 -1
- data/spec/bill_nelson_press-coldfusion.html +593 -0
- data/spec/bill_nelson_press.html +453 -572
- data/spec/rand_paul_press.html +5492 -0
- data/spec/statement_spec.rb +31 -3
- metadata +6 -2
data/spec/statement_spec.rb
CHANGED
@@ -40,13 +40,30 @@ describe Statement do
|
|
40
40
|
@results.last[:url].must_equal "http://www.gop.gov/republicans/other/relative_url_test.html"
|
41
41
|
end
|
42
42
|
|
43
|
-
it "scrapes a senate cold fusion page" do
|
43
|
+
it "scrapes a senate cold fusion page (old bill nelson)" do
|
44
|
+
skip "This test no longer relevant as Bill Nelson is off of cold fusion"
|
44
45
|
@url = "http://www.billnelson.senate.gov/news/media.cfm?year=2013"
|
45
|
-
WebMock.stub_request(:
|
46
|
+
WebMock.stub_request(:get, "http://www.billnelson.senate.gov/newsroom/press-releases?page=2013").
|
47
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
48
|
+
to_return(:status => 200, :body => File.new(File.join(File.dirname(__FILE__), 'bill_nelson_press-coldfusion.html')), :headers => {})
|
49
|
+
|
50
|
+
|
46
51
|
@results = Scraper.billnelson(year=2013)
|
47
|
-
@results.last[:url].must_equal "http://www.billnelson.senate.gov/
|
52
|
+
@results.last[:url].must_equal "http://www.billnelson.senate.gov/newsroom/press-releases/lawmakers-call-on-feds-to-investigate-use-of-supercookies"
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
it "scrapes a bill nelson page" do
|
57
|
+
@url = "http://www.billnelson.senate.gov/newsroom/press-releases?page=1"
|
58
|
+
WebMock.stub_request(:get, "http://www.billnelson.senate.gov/newsroom/press-releases?page=1").
|
59
|
+
to_return(:status => 200,
|
60
|
+
:body => File.new(File.join(File.dirname(__FILE__), 'bill_nelson_press.html')), :headers => {})
|
61
|
+
|
62
|
+
@results = Scraper.billnelson(page = 1)
|
63
|
+
@results.last[:url].must_equal "http://www.billnelson.senate.gov/newsroom/press-releases/lawmakers-call-on-feds-to-investigate-use-of-supercookies"
|
48
64
|
end
|
49
65
|
|
66
|
+
|
50
67
|
it "scrapes vitter pages for 2013" do
|
51
68
|
@vitter = "http://www.vitter.senate.gov/newsroom/press?year=2013"
|
52
69
|
WebMock.stub_request(:any, @vitter).to_return(:body => File.new(File.join(File.dirname(__FILE__), 'vitter_press.html')), :status => 200)
|
@@ -113,4 +130,15 @@ describe Statement do
|
|
113
130
|
@results.length.must_equal 10
|
114
131
|
@results.first.must_equal expected_result
|
115
132
|
end
|
133
|
+
|
134
|
+
it "scrapes Rand Paul's first page of press releases" do
|
135
|
+
@rand_paul = "http://www.paul.senate.gov/news/press?PageNum_rs=1"
|
136
|
+
WebMock.stub_request(:any, @rand_paul).to_return(:body => File.new(File.join(File.dirname(__FILE__), 'rand_paul_press.html')), :status => 200)
|
137
|
+
@results = Scraper.rand_paul(page = 1)
|
138
|
+
@results.length.must_equal 20
|
139
|
+
@results[0][:url].must_equal 'http://www.paul.senate.gov/news/press/sens-rand-paul-and-mark-warner-introduce-the-bonuses-for-cost-cutters-act-of-2015'
|
140
|
+
@results[0][:title].must_equal 'Sens. Rand Paul & Mark Warner Introduce the Bonuses for Cost-Cutters Act of 2015'
|
141
|
+
end
|
142
|
+
|
143
|
+
|
116
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Willis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/statement/utils.rb
|
171
171
|
- lib/statement/version.rb
|
172
172
|
- scraper_guide.md
|
173
|
+
- spec/bill_nelson_press-coldfusion.html
|
173
174
|
- spec/bill_nelson_press.html
|
174
175
|
- spec/butterfield_press.html
|
175
176
|
- spec/cowan_press.html
|
@@ -178,6 +179,7 @@ files:
|
|
178
179
|
- spec/ed_perlmutter_press.html
|
179
180
|
- spec/house_gop_releases.html
|
180
181
|
- spec/keating_press.html
|
182
|
+
- spec/rand_paul_press.html
|
181
183
|
- spec/richard_burr.xml
|
182
184
|
- spec/ruiz_rss.xml
|
183
185
|
- spec/statement_spec.rb
|
@@ -208,6 +210,7 @@ signing_key:
|
|
208
210
|
specification_version: 4
|
209
211
|
summary: Given a url, Statement returns links to press releases and official statements.
|
210
212
|
test_files:
|
213
|
+
- spec/bill_nelson_press-coldfusion.html
|
211
214
|
- spec/bill_nelson_press.html
|
212
215
|
- spec/butterfield_press.html
|
213
216
|
- spec/cowan_press.html
|
@@ -216,6 +219,7 @@ test_files:
|
|
216
219
|
- spec/ed_perlmutter_press.html
|
217
220
|
- spec/house_gop_releases.html
|
218
221
|
- spec/keating_press.html
|
222
|
+
- spec/rand_paul_press.html
|
219
223
|
- spec/richard_burr.xml
|
220
224
|
- spec/ruiz_rss.xml
|
221
225
|
- spec/statement_spec.rb
|