feedjira 1.3.1 → 1.4.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.
@@ -16,15 +16,15 @@ describe Feedjira::Feed do
16
16
  end
17
17
 
18
18
  it "should parse the added element out of Atom feeds" do
19
- Feedjira::Feed.parse(sample_wfw_feed).generator.should == "TypePad"
19
+ expect(Feedjira::Feed.parse(sample_wfw_feed).generator).to eq "TypePad"
20
20
  end
21
21
 
22
22
  it "should parse the added element out of Atom Feedburner feeds" do
23
- Feedjira::Parser::Atom.new.should respond_to(:generator)
23
+ expect(Feedjira::Parser::Atom.new).to respond_to(:generator)
24
24
  end
25
25
 
26
26
  it "should parse the added element out of RSS feeds" do
27
- Feedjira::Parser::RSS.new.should respond_to(:generator)
27
+ expect(Feedjira::Parser::RSS.new).to respond_to(:generator)
28
28
  end
29
29
  end
30
30
 
@@ -34,15 +34,15 @@ describe Feedjira::Feed do
34
34
  end
35
35
 
36
36
  it "should parse the added element out of Atom feeds entries" do
37
- Feedjira::Feed.parse(sample_wfw_feed).entries.first.comment_rss.should == "this is the new val"
37
+ expect(Feedjira::Feed.parse(sample_wfw_feed).entries.first.comment_rss).to eq "this is the new val"
38
38
  end
39
39
 
40
40
  it "should parse the added element out of Atom Feedburner feeds entries" do
41
- Feedjira::Parser::AtomEntry.new.should respond_to(:comment_rss)
41
+ expect(Feedjira::Parser::AtomEntry.new).to respond_to(:comment_rss)
42
42
  end
43
43
 
44
44
  it "should parse the added element out of RSS feeds entries" do
45
- Feedjira::Parser::RSSEntry.new.should respond_to(:comment_rss)
45
+ expect(Feedjira::Parser::RSSEntry.new).to respond_to(:comment_rss)
46
46
  end
47
47
  end
48
48
 
@@ -51,7 +51,7 @@ describe Feedjira::Feed do
51
51
 
52
52
  it 'invokes the parser and passes the xml' do
53
53
  parser = double 'Parser', parse: nil
54
- parser.should_receive(:parse).with xml
54
+ expect(parser).to receive(:parse).with xml
55
55
  Feedjira::Feed.parse_with parser, xml
56
56
  end
57
57
 
@@ -70,83 +70,83 @@ describe Feedjira::Feed do
70
70
  context "when there's an available parser" do
71
71
  it "should parse an rdf feed" do
72
72
  feed = Feedjira::Feed.parse(sample_rdf_feed)
73
- feed.title.should == "HREF Considered Harmful"
74
- feed.entries.first.published.should == Time.parse_safely("Tue Sep 02 19:50:07 UTC 2008")
75
- feed.entries.size.should == 10
73
+ expect(feed.title).to eq "HREF Considered Harmful"
74
+ expect(feed.entries.first.published).to eq Time.parse_safely("Tue Sep 02 19:50:07 UTC 2008")
75
+ expect(feed.entries.size).to eq 10
76
76
  end
77
77
 
78
78
  it "should parse an rss feed" do
79
79
  feed = Feedjira::Feed.parse(sample_rss_feed)
80
- feed.title.should == "Tender Lovemaking"
81
- feed.entries.first.published.should == Time.parse_safely("Thu Dec 04 17:17:49 UTC 2008")
82
- feed.entries.size.should == 10
80
+ expect(feed.title).to eq "Tender Lovemaking"
81
+ expect(feed.entries.first.published).to eq Time.parse_safely("Thu Dec 04 17:17:49 UTC 2008")
82
+ expect(feed.entries.size).to eq 10
83
83
  end
84
84
 
85
85
  it "should parse an atom feed" do
86
86
  feed = Feedjira::Feed.parse(sample_atom_feed)
87
- feed.title.should == "Amazon Web Services Blog"
88
- feed.entries.first.published.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
89
- feed.entries.size.should == 10
87
+ expect(feed.title).to eq "Amazon Web Services Blog"
88
+ expect(feed.entries.first.published).to eq Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
89
+ expect(feed.entries.size).to eq 10
90
90
  end
91
91
 
92
92
  it "should parse an feedburner atom feed" do
93
93
  feed = Feedjira::Feed.parse(sample_feedburner_atom_feed)
94
- feed.title.should == "Paul Dix Explains Nothing"
95
- feed.entries.first.published.should == Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
96
- feed.entries.size.should == 5
94
+ expect(feed.title).to eq "Paul Dix Explains Nothing"
95
+ expect(feed.entries.first.published).to eq Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
96
+ expect(feed.entries.size).to eq 5
97
97
  end
98
98
 
99
99
  it "should parse an itunes feed" do
100
100
  feed = Feedjira::Feed.parse(sample_itunes_feed)
101
- feed.title.should == "All About Everything"
102
- feed.entries.first.published.should == Time.parse_safely("Wed, 15 Jun 2005 19:00:00 GMT")
103
- feed.entries.size.should == 3
101
+ expect(feed.title).to eq "All About Everything"
102
+ expect(feed.entries.first.published).to eq Time.parse_safely("Wed, 15 Jun 2005 19:00:00 GMT")
103
+ expect(feed.entries.size).to eq 3
104
104
  end
105
105
  end
106
106
 
107
107
  context "when there's no available parser" do
108
108
  it "raises Feedjira::NoParserAvailable" do
109
- proc {
109
+ expect {
110
110
  Feedjira::Feed.parse("I'm an invalid feed")
111
- }.should raise_error(Feedjira::NoParserAvailable)
111
+ }.to raise_error(Feedjira::NoParserAvailable)
112
112
  end
113
113
  end
114
114
 
115
115
  it "should parse an feedburner rss feed" do
116
116
  feed = Feedjira::Feed.parse(sample_rss_feed_burner_feed)
117
- feed.title.should == "TechCrunch"
118
- feed.entries.first.published.should == Time.parse_safely("Wed Nov 02 17:25:27 UTC 2011")
119
- feed.entries.size.should == 20
117
+ expect(feed.title).to eq "TechCrunch"
118
+ expect(feed.entries.first.published).to eq Time.parse_safely("Wed Nov 02 17:25:27 UTC 2011")
119
+ expect(feed.entries.size).to eq 20
120
120
  end
121
121
  end
122
122
 
123
123
  describe "#determine_feed_parser_for_xml" do
124
124
  it 'should return the Feedjira::Parser::GoogleDocsAtom calss for a Google Docs atom feed' do
125
- Feedjira::Feed.determine_feed_parser_for_xml(sample_google_docs_list_feed).should == Feedjira::Parser::GoogleDocsAtom
125
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_google_docs_list_feed)).to eq Feedjira::Parser::GoogleDocsAtom
126
126
  end
127
127
 
128
- it "should return the Feedjira::Parser::Atom class for an atom feed" do
129
- Feedjira::Feed.determine_feed_parser_for_xml(sample_atom_feed).should == Feedjira::Parser::Atom
128
+ it "should return the expect(Feedjira::Parser::Atom class for an atom feed" do
129
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_atom_feed)).to eq Feedjira::Parser::Atom
130
130
  end
131
131
 
132
- it "should return the Feedjira::Parser::AtomFeedBurner class for an atom feedburner feed" do
133
- Feedjira::Feed.determine_feed_parser_for_xml(sample_feedburner_atom_feed).should == Feedjira::Parser::AtomFeedBurner
132
+ it "should return the expect(Feedjira::Parser::AtomFeedBurner class for an atom feedburner feed" do
133
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_feedburner_atom_feed)).to eq Feedjira::Parser::AtomFeedBurner
134
134
  end
135
135
 
136
- it "should return the Feedjira::Parser::RSS class for an rdf/rss 1.0 feed" do
137
- Feedjira::Feed.determine_feed_parser_for_xml(sample_rdf_feed).should == Feedjira::Parser::RSS
136
+ it "should return the expect(Feedjira::Parser::RSS class for an rdf/rss 1.0 feed" do
137
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_rdf_feed)).to eq Feedjira::Parser::RSS
138
138
  end
139
139
 
140
- it "should return the Feedjira::Parser::RSSFeedBurner class for an rss feedburner feed" do
141
- Feedjira::Feed.determine_feed_parser_for_xml(sample_rss_feed_burner_feed).should == Feedjira::Parser::RSSFeedBurner
140
+ it "should return the expect(Feedjira::Parser::RSSFeedBurner class for an rss feedburner feed" do
141
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_rss_feed_burner_feed)).to eq Feedjira::Parser::RSSFeedBurner
142
142
  end
143
143
 
144
- it "should return the Feedjira::Parser::RSS object for an rss 2.0 feed" do
145
- Feedjira::Feed.determine_feed_parser_for_xml(sample_rss_feed).should == Feedjira::Parser::RSS
144
+ it "should return the expect(Feedjira::Parser::RSS object for an rss 2.0 feed" do
145
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_rss_feed)).to eq Feedjira::Parser::RSS
146
146
  end
147
147
 
148
- it "should return a Feedjira::Parser::RSS object for an itunes feed" do
149
- Feedjira::Feed.determine_feed_parser_for_xml(sample_itunes_feed).should == Feedjira::Parser::ITunesRSS
148
+ it "should return a expect(Feedjira::Parser::RSS object for an itunes feed" do
149
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(sample_itunes_feed)).to eq Feedjira::Parser::ITunesRSS
150
150
  end
151
151
 
152
152
  end
@@ -165,33 +165,33 @@ describe Feedjira::Feed do
165
165
  it "sets defaults on curl" do
166
166
  Feedjira::Feed.setup_easy curl
167
167
 
168
- curl.headers["User-Agent"].should eq Feedjira::Feed::USER_AGENT
169
- curl.follow_location.should eq true
168
+ expect(curl.headers["User-Agent"]).to eq Feedjira::Feed::USER_AGENT
169
+ expect(curl.follow_location).to eq true
170
170
  end
171
171
 
172
172
  it "allows user agent over-ride" do
173
173
  Feedjira::Feed.setup_easy(curl, user_agent: '007')
174
- curl.headers["User-Agent"].should eq '007'
174
+ expect(curl.headers["User-Agent"]).to eq '007'
175
175
  end
176
176
 
177
177
  it "allows to set language" do
178
178
  Feedjira::Feed.setup_easy(curl, language: 'en-US')
179
- curl.headers["Accept-Language"].should eq 'en-US'
179
+ expect(curl.headers["Accept-Language"]).to eq 'en-US'
180
180
  end
181
181
 
182
182
  it "enables compression" do
183
183
  Feedjira::Feed.setup_easy(curl, compress: true)
184
- curl.headers["Accept-encoding"].should eq 'gzip, deflate'
184
+ expect(curl.headers["Accept-encoding"]).to eq 'gzip, deflate'
185
185
  end
186
186
 
187
187
  it "enables compression even when you act like you don't want it" do
188
188
  Feedjira::Feed.setup_easy(curl, compress: false)
189
- curl.headers["Accept-encoding"].should eq 'gzip, deflate'
189
+ expect(curl.headers["Accept-encoding"]).to eq 'gzip, deflate'
190
190
  end
191
191
 
192
192
  it "sets up http auth" do
193
193
  Feedjira::Feed.setup_easy(curl, http_authentication: ['user', 'pass'])
194
- curl.userpwd.should eq 'user:pass'
194
+ expect(curl.userpwd).to eq 'user:pass'
195
195
  end
196
196
 
197
197
  it "passes known options to curl" do
@@ -212,7 +212,7 @@ describe Feedjira::Feed do
212
212
 
213
213
  known_options.each do |option|
214
214
  key, value = option
215
- curl.send(key).should eq value
215
+ expect(curl.send(key)).to eq value
216
216
  end
217
217
  end
218
218
 
@@ -224,16 +224,16 @@ describe Feedjira::Feed do
224
224
  describe "when adding feed types" do
225
225
  it "should prioritize added types over the built in ones" do
226
226
  feed_text = "Atom asdf"
227
- Feedjira::Parser::Atom.stub(:able_to_parse?).and_return(true)
227
+ allow(Feedjira::Parser::Atom).to receive(:able_to_parse?).and_return(true)
228
228
  new_feed_type = Class.new do
229
229
  def self.able_to_parse?(val)
230
230
  true
231
231
  end
232
232
  end
233
233
 
234
- new_feed_type.should be_able_to_parse(feed_text)
234
+ expect(new_feed_type).to be_able_to_parse(feed_text)
235
235
  Feedjira::Feed.add_feed_class(new_feed_type)
236
- Feedjira::Feed.determine_feed_parser_for_xml(feed_text).should == new_feed_type
236
+ expect(Feedjira::Feed.determine_feed_parser_for_xml(feed_text)).to eq new_feed_type
237
237
 
238
238
  # this is a hack so that this doesn't break the rest of the tests
239
239
  Feedjira::Feed.feed_classes.reject! {|o| o == new_feed_type }
@@ -246,11 +246,11 @@ describe Feedjira::Feed do
246
246
  end
247
247
 
248
248
  it "should return the etag from the header if it exists" do
249
- Feedjira::Feed.etag_from_header(@header).should == "ziEyTl4q9GH04BR4jgkImd0GvSE"
249
+ expect(Feedjira::Feed.etag_from_header(@header)).to eq "ziEyTl4q9GH04BR4jgkImd0GvSE"
250
250
  end
251
251
 
252
252
  it "should return nil if there is no etag in the header" do
253
- Feedjira::Feed.etag_from_header("foo").should be_nil
253
+ expect(Feedjira::Feed.etag_from_header("foo")).to be_nil
254
254
  end
255
255
 
256
256
  end
@@ -261,11 +261,11 @@ describe Feedjira::Feed do
261
261
  end
262
262
 
263
263
  it "should return the last modified date from the header if it exists" do
264
- Feedjira::Feed.last_modified_from_header(@header).should == Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
264
+ expect(Feedjira::Feed.last_modified_from_header(@header)).to eq Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
265
265
  end
266
266
 
267
267
  it "should return nil if there is no last modified date in the header" do
268
- Feedjira::Feed.last_modified_from_header("foo").should be_nil
268
+ expect(Feedjira::Feed.last_modified_from_header("foo")).to be_nil
269
269
  end
270
270
  end
271
271
 
@@ -282,72 +282,73 @@ describe Feedjira::Feed do
282
282
  @multi = double('curl_multi', :add => true, :perform => true)
283
283
  @curl_easy = double('curl_easy')
284
284
  @curl = double('curl', :headers => {}, :follow_location= => true, :on_failure => true, :on_complete => true)
285
- @curl.stub(:on_success).and_yield(@cmock)
285
+ allow(@curl).to receive(:on_success).and_yield(@cmock)
286
286
 
287
- Curl::Multi.stub(:new).and_return(@multi)
288
- Curl::Easy.stub(:new).and_yield(@curl).and_return(@curl_easy)
287
+ allow(Curl::Multi).to receive(:new).and_return(@multi)
288
+ allow(Curl::Easy).to receive(:new).and_yield(@curl).and_return(@curl_easy)
289
289
  end
290
290
 
291
291
  it "should set user agent if it's passed as an option" do
292
292
  Feedjira::Feed.fetch_raw(@paul_feed[:url], :user_agent => 'Custom Useragent')
293
- @curl.headers['User-Agent'].should == 'Custom Useragent'
293
+ expect(@curl.headers['User-Agent']).to eq 'Custom Useragent'
294
294
  end
295
295
 
296
296
  it "should set user agent to default if it's not passed as an option" do
297
297
  Feedjira::Feed.fetch_raw(@paul_feed[:url])
298
- @curl.headers['User-Agent'].should == Feedjira::Feed::USER_AGENT
298
+ expect(@curl.headers['User-Agent']).to eq Feedjira::Feed::USER_AGENT
299
299
  end
300
300
 
301
301
  it "should set if modified since as an option if passed" do
302
302
  Feedjira::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT"))
303
- @curl.headers["If-Modified-Since"].should == 'Wed, 28 Jan 2009 04:10:32 GMT'
303
+ expect(@curl.headers["If-Modified-Since"]).to eq 'Wed, 28 Jan 2009 04:10:32 GMT'
304
304
  end
305
305
 
306
306
  it "should set if none match as an option if passed" do
307
307
  Feedjira::Feed.fetch_raw(@paul_feed[:url], :if_none_match => 'ziEyTl4q9GH04BR4jgkImd0GvSE')
308
- @curl.headers["If-None-Match"].should == 'ziEyTl4q9GH04BR4jgkImd0GvSE'
308
+ expect(@curl.headers["If-None-Match"]).to eq 'ziEyTl4q9GH04BR4jgkImd0GvSE'
309
309
  end
310
310
 
311
311
  it 'should set userpwd for http basic authentication if :http_authentication is passed' do
312
- @curl.should_receive(:userpwd=).with('username:password')
312
+ expect(@curl).to receive(:userpwd=).with('username:password')
313
313
  Feedjira::Feed.fetch_raw(@paul_feed[:url], :http_authentication => ['username', 'password'])
314
314
  end
315
315
 
316
316
  it 'should set accepted encodings' do
317
317
  Feedjira::Feed.fetch_raw(@paul_feed[:url], :compress => true)
318
- @curl.headers["Accept-encoding"].should == 'gzip, deflate'
318
+ expect(@curl.headers["Accept-encoding"]).to eq 'gzip, deflate'
319
319
  end
320
320
 
321
321
  it "should return raw xml" do
322
- Feedjira::Feed.fetch_raw(@paul_feed[:url]).should =~ /^#{Regexp.escape('<?xml version="1.0" encoding="UTF-8"?>')}/
322
+ raw_xml = Feedjira::Feed.fetch_raw @paul_feed[:url]
323
+ expect(raw_xml).to match /^#{Regexp.escape('<?xml version="1.0" encoding="UTF-8"?>')}/
323
324
  end
324
325
 
325
326
  it "should take multiple feed urls and return a hash of urls and response xml" do
326
327
  multi = double('curl_multi', :add => true, :perform => true)
327
- Curl::Multi.stub(:new).and_return(multi)
328
+ allow(Curl::Multi).to receive(:new).and_return(multi)
328
329
 
329
330
  paul_response = double('paul_response', :header_str => '', :body_str => @paul_feed[:xml] )
330
331
  trotter_response = double('trotter_response', :header_str => '', :body_str => @trotter_feed[:xml] )
331
332
 
332
333
  paul_curl = double('paul_curl', :headers => {}, :follow_location= => true, :on_failure => true, :on_complete => true)
333
- paul_curl.stub(:on_success).and_yield(paul_response)
334
+ allow(paul_curl).to receive(:on_success).and_yield(paul_response)
334
335
 
335
336
  trotter_curl = double('trotter_curl', :headers => {}, :follow_location= => true, :on_failure => true, :on_complete => true)
336
- trotter_curl.stub(:on_success).and_yield(trotter_response)
337
+ allow(trotter_curl).to receive(:on_success).and_yield(trotter_response)
337
338
 
338
- Curl::Easy.should_receive(:new).with(@paul_feed[:url]).ordered.and_yield(paul_curl)
339
- Curl::Easy.should_receive(:new).with(@trotter_feed[:url]).ordered.and_yield(trotter_curl)
339
+ expect(Curl::Easy).to receive(:new).with(@paul_feed[:url]).ordered.and_yield(paul_curl)
340
+ expect(Curl::Easy).to receive(:new).with(@trotter_feed[:url]).ordered.and_yield(trotter_curl)
340
341
 
341
342
  results = Feedjira::Feed.fetch_raw([@paul_feed[:url], @trotter_feed[:url]])
342
- results.keys.should include(@paul_feed[:url])
343
- results.keys.should include(@trotter_feed[:url])
344
- results[@paul_feed[:url]].should =~ /Paul Dix/
345
- results[@trotter_feed[:url]].should =~ /Trotter Cashion/
343
+ expect(results.keys).to include(@paul_feed[:url])
344
+ expect(results.keys).to include(@trotter_feed[:url])
345
+ expect(results[@paul_feed[:url]]).to match /Paul Dix/
346
+ expect(results[@trotter_feed[:url]]).to match /Trotter Cashion/
346
347
  end
347
348
 
348
349
  it "should always return a hash when passed an array" do
349
350
  results = Feedjira::Feed.fetch_raw([@paul_feed[:url]])
350
- results.class.should == Hash
351
+ expect(results.class).to eq Hash
351
352
  end
352
353
  end
353
354
 
@@ -355,71 +356,71 @@ describe Feedjira::Feed do
355
356
  before(:each) do
356
357
  allow_message_expectations_on_nil
357
358
  @multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
358
- @multi.stub(:add)
359
+ allow(@multi).to receive(:add)
359
360
  @easy_curl = Curl::Easy.new(@paul_feed[:url])
360
361
 
361
- Curl::Easy.should_receive(:new).and_yield(@easy_curl)
362
+ allow(Curl::Easy).to receive(:new).and_yield(@easy_curl)
362
363
  end
363
364
 
364
365
  it "should set user agent if it's passed as an option" do
365
366
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :user_agent => 'My cool application')
366
- @easy_curl.headers["User-Agent"].should == 'My cool application'
367
+ expect(@easy_curl.headers["User-Agent"]).to eq 'My cool application'
367
368
  end
368
369
 
369
370
  it "should set user agent to default if it's not passed as an option" do
370
371
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
371
- @easy_curl.headers["User-Agent"].should == Feedjira::Feed::USER_AGENT
372
+ expect(@easy_curl.headers["User-Agent"]).to eq Feedjira::Feed::USER_AGENT
372
373
  end
373
374
 
374
375
  it "should set if modified since as an option if passed" do
375
376
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse_safely("Jan 25 2009 04:10:32 GMT"))
376
- @easy_curl.headers["If-Modified-Since"].should == 'Sun, 25 Jan 2009 04:10:32 GMT'
377
+ expect(@easy_curl.headers["If-Modified-Since"]).to eq 'Sun, 25 Jan 2009 04:10:32 GMT'
377
378
  end
378
379
 
379
380
  it 'should set follow location to true' do
380
- @easy_curl.should_receive(:follow_location=).with(true)
381
+ expect(@easy_curl).to receive(:follow_location=).with(true)
381
382
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
382
383
  end
383
384
 
384
385
  it 'should set userpwd for http basic authentication if :http_authentication is passed' do
385
386
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :http_authentication => ['myusername', 'mypassword'])
386
- @easy_curl.userpwd.should == 'myusername:mypassword'
387
+ expect(@easy_curl.userpwd).to eq 'myusername:mypassword'
387
388
  end
388
389
 
389
390
  it 'should set accepted encodings' do
390
391
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {:compress => true})
391
- @easy_curl.headers["Accept-encoding"].should == 'gzip, deflate'
392
+ expect(@easy_curl.headers["Accept-encoding"]).to eq 'gzip, deflate'
392
393
  end
393
394
 
394
395
  it "should set if_none_match as an option if passed" do
395
396
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_none_match => 'ziEyTl4q9GH04BR4jgkImd0GvSE')
396
- @easy_curl.headers["If-None-Match"].should == 'ziEyTl4q9GH04BR4jgkImd0GvSE'
397
+ expect(@easy_curl.headers["If-None-Match"]).to eq 'ziEyTl4q9GH04BR4jgkImd0GvSE'
397
398
  end
398
399
 
399
400
  describe 'on success' do
400
401
  before(:each) do
401
402
  @feed = double('feed', :feed_url= => true, :etag= => true, :last_modified= => true)
402
- Feedjira::Feed.stub(:decode_content).and_return(@paul_feed[:xml])
403
- Feedjira::Feed.stub(:determine_feed_parser_for_xml).and_return(Feedjira::Parser::AtomFeedBurner)
404
- Feedjira::Parser::AtomFeedBurner.stub(:parse).and_return(@feed)
405
- Feedjira::Feed.stub(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
406
- Feedjira::Feed.stub(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
403
+ allow(Feedjira::Feed).to receive(:decode_content).and_return(@paul_feed[:xml])
404
+ allow(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).and_return(Feedjira::Parser::AtomFeedBurner)
405
+ allow(Feedjira::Parser::AtomFeedBurner).to receive(:parse).and_return(@feed)
406
+ allow(Feedjira::Feed).to receive(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
407
+ allow(Feedjira::Feed).to receive(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
407
408
  end
408
409
 
409
410
  it 'should decode the response body' do
410
- Feedjira::Feed.should_receive(:decode_content).with(@easy_curl).and_return(@paul_feed[:xml])
411
+ expect(Feedjira::Feed).to receive(:decode_content).with(@easy_curl).and_return(@paul_feed[:xml])
411
412
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
412
413
  @easy_curl.on_success.call(@easy_curl)
413
414
  end
414
415
 
415
416
  it 'should determine the xml parser class' do
416
- Feedjira::Feed.should_receive(:determine_feed_parser_for_xml).with(@paul_feed[:xml]).and_return(Feedjira::Parser::AtomFeedBurner)
417
+ expect(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).with(@paul_feed[:xml]).and_return(Feedjira::Parser::AtomFeedBurner)
417
418
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
418
419
  @easy_curl.on_success.call(@easy_curl)
419
420
  end
420
421
 
421
422
  it 'should parse the xml' do
422
- Feedjira::Parser::AtomFeedBurner.should_receive(:parse).
423
+ expect(Feedjira::Parser::AtomFeedBurner).to receive(:parse).
423
424
  with(@paul_feed[:xml]).and_return(@feed)
424
425
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
425
426
  @easy_curl.on_success.call(@easy_curl)
@@ -427,20 +428,20 @@ describe Feedjira::Feed do
427
428
 
428
429
  describe 'when a compatible xml parser class is found' do
429
430
  it 'should set the last effective url to the feed url' do
430
- @easy_curl.should_receive(:last_effective_url).and_return(@paul_feed[:url])
431
- @feed.should_receive(:feed_url=).with(@paul_feed[:url])
431
+ expect(@easy_curl).to receive(:last_effective_url).and_return(@paul_feed[:url])
432
+ expect(@feed).to receive(:feed_url=).with(@paul_feed[:url])
432
433
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
433
434
  @easy_curl.on_success.call(@easy_curl)
434
435
  end
435
436
 
436
437
  it 'should set the etags on the feed' do
437
- @feed.should_receive(:etag=).with('ziEyTl4q9GH04BR4jgkImd0GvSE')
438
+ expect(@feed).to receive(:etag=).with('ziEyTl4q9GH04BR4jgkImd0GvSE')
438
439
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
439
440
  @easy_curl.on_success.call(@easy_curl)
440
441
  end
441
442
 
442
443
  it 'should set the last modified on the feed' do
443
- @feed.should_receive(:last_modified=).with('Wed, 28 Jan 2009 04:10:32 GMT')
444
+ expect(@feed).to receive(:last_modified=).with('Wed, 28 Jan 2009 04:10:32 GMT')
444
445
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
445
446
  @easy_curl.on_success.call(@easy_curl)
446
447
  end
@@ -450,13 +451,13 @@ describe Feedjira::Feed do
450
451
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], responses, {})
451
452
  @easy_curl.on_success.call(@easy_curl)
452
453
 
453
- responses.length.should == 1
454
- responses['http://feeds.feedburner.com/PaulDixExplainsNothing'].should == @feed
454
+ expect(responses.length).to eq 1
455
+ expect(responses['http://feeds.feedburner.com/PaulDixExplainsNothing']).to eq @feed
455
456
  end
456
457
 
457
458
  it 'should call proc if :on_success option is passed' do
458
459
  success = lambda { |url, feed| }
459
- success.should_receive(:call).with(@paul_feed[:url], @feed)
460
+ expect(success).to receive(:call).with(@paul_feed[:url], @feed)
460
461
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { :on_success => success })
461
462
  @easy_curl.on_success.call(@easy_curl)
462
463
  end
@@ -464,9 +465,9 @@ describe Feedjira::Feed do
464
465
  describe 'when the parser raises an exception' do
465
466
  it 'invokes the on_failure callback with that exception' do
466
467
  failure = double 'Failure callback', arity: 2
467
- failure.should_receive(:call).with(@easy_curl, an_instance_of(Hell))
468
+ expect(failure).to receive(:call).with(@easy_curl, an_instance_of(Hell))
468
469
 
469
- Feedjira::Parser::AtomFeedBurner.should_receive(:parse).and_raise Hell
470
+ expect(Feedjira::Parser::AtomFeedBurner).to receive(:parse).and_raise Hell
470
471
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { on_failure: failure })
471
472
 
472
473
  @easy_curl.on_success.call(@easy_curl)
@@ -475,12 +476,12 @@ describe Feedjira::Feed do
475
476
 
476
477
  describe 'when the parser invokes its on_failure callback' do
477
478
  before(:each) do
478
- Feedjira::Feed.stub(:determine_feed_parser_for_xml).and_return FailParser
479
+ allow(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).and_return FailParser
479
480
  end
480
481
 
481
482
  it 'invokes the on_failure callback' do
482
483
  failure = double 'Failure callback', arity: 2
483
- failure.should_receive(:call).with(@easy_curl, an_instance_of(RuntimeError))
484
+ expect(failure).to receive(:call).with(@easy_curl, an_instance_of(RuntimeError))
484
485
 
485
486
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { on_failure: failure })
486
487
  @easy_curl.on_success.call(@easy_curl)
@@ -491,9 +492,9 @@ describe Feedjira::Feed do
491
492
  describe 'when no compatible xml parser class is found' do
492
493
  it 'invokes the on_failure callback' do
493
494
  failure = double 'Failure callback', arity: 2
494
- failure.should_receive(:call).with(@easy_curl, "Can't determine a parser")
495
+ expect(failure).to receive(:call).with(@easy_curl, "Can't determine a parser")
495
496
 
496
- Feedjira::Feed.should_receive(:determine_feed_parser_for_xml).and_return nil
497
+ allow(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).and_return nil
497
498
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { on_failure: failure })
498
499
 
499
500
  @easy_curl.on_success.call(@easy_curl)
@@ -506,14 +507,14 @@ describe Feedjira::Feed do
506
507
  @headers = "HTTP/1.0 500 Something Bad\r\nDate: Thu, 29 Jan 2009 03:55:24 GMT\r\nServer: Apache\r\nX-FB-Host: chi-write6\r\nLast-Modified: Wed, 28 Jan 2009 04:10:32 GMT\r\n"
507
508
  @body = 'Sorry, something broke'
508
509
 
509
- @easy_curl.stub(:response_code).and_return(500)
510
- @easy_curl.stub(:header_str).and_return(@headers)
511
- @easy_curl.stub(:body_str).and_return(@body)
510
+ allow(@easy_curl).to receive(:response_code).and_return(500)
511
+ allow(@easy_curl).to receive(:header_str).and_return(@headers)
512
+ allow(@easy_curl).to receive(:body_str).and_return(@body)
512
513
  end
513
514
 
514
515
  it 'should call proc if :on_failure option is passed' do
515
516
  failure = double 'Failure callback', arity: 2
516
- failure.should_receive(:call).with(@easy_curl, nil)
517
+ expect(failure).to receive(:call).with(@easy_curl, nil)
517
518
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { :on_failure => failure })
518
519
  @easy_curl.on_failure.call(@easy_curl)
519
520
  end
@@ -523,8 +524,8 @@ describe Feedjira::Feed do
523
524
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], responses, {})
524
525
  @easy_curl.on_failure.call(@easy_curl)
525
526
 
526
- responses.length.should == 1
527
- responses[@paul_feed[:url]].should == 500
527
+ expect(responses.length).to eq 1
528
+ expect(responses[@paul_feed[:url]]).to eq 500
528
529
  end
529
530
  end
530
531
 
@@ -533,14 +534,14 @@ describe Feedjira::Feed do
533
534
  @headers = "HTTP/1.0 404 Not Found\r\nDate: Thu, 29 Jan 2009 03:55:24 GMT\r\nServer: Apache\r\nX-FB-Host: chi-write6\r\nLast-Modified: Wed, 28 Jan 2009 04:10:32 GMT\r\n"
534
535
  @body = 'Page could not be found.'
535
536
 
536
- @easy_curl.stub(:response_code).and_return(404)
537
- @easy_curl.stub(:header_str).and_return(@headers)
538
- @easy_curl.stub(:body_str).and_return(@body)
537
+ allow(@easy_curl).to receive(:response_code).and_return(404)
538
+ allow(@easy_curl).to receive(:header_str).and_return(@headers)
539
+ allow(@easy_curl).to receive(:body_str).and_return(@body)
539
540
  end
540
541
 
541
542
  it 'should call proc if :on_failure option is passed' do
542
543
  complete = double 'Failure callback', arity: 2
543
- complete.should_receive(:call).with(@easy_curl, 'Server returned a 404')
544
+ expect(complete).to receive(:call).with(@easy_curl, 'Server returned a 404')
544
545
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { :on_failure => complete })
545
546
  @easy_curl.on_missing.call(@easy_curl)
546
547
  end
@@ -550,8 +551,8 @@ describe Feedjira::Feed do
550
551
  Feedjira::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], responses, {})
551
552
  @easy_curl.on_complete.call(@easy_curl)
552
553
 
553
- responses.length.should == 1
554
- responses[@paul_feed[:url]].should == 404
554
+ expect(responses.length).to eq 1
555
+ expect(responses[@paul_feed[:url]]).to eq 404
555
556
  end
556
557
  end
557
558
  end
@@ -560,79 +561,79 @@ describe Feedjira::Feed do
560
561
  before(:each) do
561
562
  allow_message_expectations_on_nil
562
563
  @multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
563
- @multi.stub(:add)
564
+ allow(@multi).to receive(:add)
564
565
  @easy_curl = Curl::Easy.new(@paul_feed[:url])
565
566
  @feed = Feedjira::Feed.parse(sample_feedburner_atom_feed)
566
567
 
567
- Curl::Easy.should_receive(:new).and_yield(@easy_curl)
568
+ allow(Curl::Easy).to receive(:new).and_yield(@easy_curl)
568
569
  end
569
570
 
570
571
  it "should set user agent if it's passed as an option" do
571
572
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, :user_agent => 'My cool application')
572
- @easy_curl.headers["User-Agent"].should == 'My cool application'
573
+ expect(@easy_curl.headers["User-Agent"]).to eq 'My cool application'
573
574
  end
574
575
 
575
576
  it "should set user agent to default if it's not passed as an option" do
576
577
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
577
- @easy_curl.headers["User-Agent"].should == Feedjira::Feed::USER_AGENT
578
+ expect(@easy_curl.headers["User-Agent"]).to eq Feedjira::Feed::USER_AGENT
578
579
  end
579
580
 
580
581
  it "should set if modified since as an option if passed" do
581
582
  modified_time = Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
582
583
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {:if_modified_since => modified_time})
583
- modified_time.should be > @feed.last_modified
584
+ expect(modified_time).to be > @feed.last_modified
584
585
 
585
- @easy_curl.headers["If-Modified-Since"].should == modified_time
586
+ expect(@easy_curl.headers["If-Modified-Since"]).to eq modified_time
586
587
  end
587
588
 
588
589
  it 'should set follow location to true' do
589
- @easy_curl.should_receive(:follow_location=).with(true)
590
+ expect(@easy_curl).to receive(:follow_location=).with(true)
590
591
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
591
592
  end
592
593
 
593
594
  it 'should set userpwd for http basic authentication if :http_authentication is passed' do
594
595
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, :http_authentication => ['myusername', 'mypassword'])
595
- @easy_curl.userpwd.should == 'myusername:mypassword'
596
+ expect(@easy_curl.userpwd).to eq 'myusername:mypassword'
596
597
  end
597
598
 
598
599
  it "should set if_none_match as an option if passed" do
599
600
  @feed.etag = 'ziEyTl4q9GH04BR4jgkImd0GvSE'
600
601
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
601
- @easy_curl.headers["If-None-Match"].should == 'ziEyTl4q9GH04BR4jgkImd0GvSE'
602
+ expect(@easy_curl.headers["If-None-Match"]).to eq 'ziEyTl4q9GH04BR4jgkImd0GvSE'
602
603
  end
603
604
 
604
605
  describe 'on success' do
605
606
  before(:each) do
606
607
  @new_feed = @feed.clone
607
- @feed.stub(:update_from_feed)
608
- Feedjira::Feed.stub(:decode_content).and_return(@paul_feed[:xml])
609
- Feedjira::Feed.stub(:determine_feed_parser_for_xml).and_return(Feedjira::Parser::AtomFeedBurner)
610
- Feedjira::Parser::AtomFeedBurner.stub(:parse).and_return(@new_feed)
611
- Feedjira::Feed.stub(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
612
- Feedjira::Feed.stub(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
608
+ allow(@feed).to receive(:update_from_feed)
609
+ allow(Feedjira::Feed).to receive(:decode_content).and_return(@paul_feed[:xml])
610
+ allow(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).and_return(Feedjira::Parser::AtomFeedBurner)
611
+ allow(Feedjira::Parser::AtomFeedBurner).to receive(:parse).and_return(@new_feed)
612
+ allow(Feedjira::Feed).to receive(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
613
+ allow(Feedjira::Feed).to receive(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
613
614
  end
614
615
 
615
616
  it 'should parse the updated feed' do
616
- Feedjira::Parser::AtomFeedBurner.should_receive(:parse).and_return(@new_feed)
617
+ expect(Feedjira::Parser::AtomFeedBurner).to receive(:parse).and_return(@new_feed)
617
618
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
618
619
  @easy_curl.on_success.call(@easy_curl)
619
620
  end
620
621
 
621
622
  it 'should set the last effective url to the feed url' do
622
- @easy_curl.should_receive(:last_effective_url).and_return(@paul_feed[:url])
623
- @new_feed.should_receive(:feed_url=).with(@paul_feed[:url])
623
+ expect(@easy_curl).to receive(:last_effective_url).and_return(@paul_feed[:url])
624
+ expect(@new_feed).to receive(:feed_url=).with(@paul_feed[:url])
624
625
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
625
626
  @easy_curl.on_success.call(@easy_curl)
626
627
  end
627
628
 
628
629
  it 'should set the etags on the feed' do
629
- @new_feed.should_receive(:etag=).with('ziEyTl4q9GH04BR4jgkImd0GvSE')
630
+ expect(@new_feed).to receive(:etag=).with('ziEyTl4q9GH04BR4jgkImd0GvSE')
630
631
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
631
632
  @easy_curl.on_success.call(@easy_curl)
632
633
  end
633
634
 
634
635
  it 'should set the last modified on the feed' do
635
- @new_feed.should_receive(:last_modified=).with('Wed, 28 Jan 2009 04:10:32 GMT')
636
+ expect(@new_feed).to receive(:last_modified=).with('Wed, 28 Jan 2009 04:10:32 GMT')
636
637
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
637
638
  @easy_curl.on_success.call(@easy_curl)
638
639
  end
@@ -642,31 +643,31 @@ describe Feedjira::Feed do
642
643
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], responses, {})
643
644
  @easy_curl.on_success.call(@easy_curl)
644
645
 
645
- responses.length.should == 1
646
- responses['http://feeds.feedburner.com/PaulDixExplainsNothing'].should == @feed
646
+ expect(responses.length).to eq 1
647
+ expect(responses['http://feeds.feedburner.com/PaulDixExplainsNothing']).to eq @feed
647
648
  end
648
649
 
649
650
  it 'should call proc if :on_success option is passed' do
650
651
  success = lambda { |feed| }
651
- success.should_receive(:call).with(@feed)
652
+ expect(success).to receive(:call).with(@feed)
652
653
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, { :on_success => success })
653
654
  @easy_curl.on_success.call(@easy_curl)
654
655
  end
655
656
 
656
657
  it 'should call update from feed on the old feed with the updated feed' do
657
- @feed.should_receive(:update_from_feed).with(@new_feed)
658
+ expect(@feed).to receive(:update_from_feed).with(@new_feed)
658
659
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
659
660
  @easy_curl.on_success.call(@easy_curl)
660
661
  end
661
662
 
662
663
  describe 'when the parser invokes its on_failure callback' do
663
664
  before(:each) do
664
- Feedjira::Feed.stub(:determine_feed_parser_for_xml).and_return FailParser
665
+ allow(Feedjira::Feed).to receive(:determine_feed_parser_for_xml).and_return FailParser
665
666
  end
666
667
 
667
668
  it 'invokes the on_failure callback' do
668
669
  failure = double 'Failure callback', arity: 2
669
- failure.should_receive(:call)
670
+ expect(failure).to receive(:call)
670
671
 
671
672
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, { on_failure: failure })
672
673
  @easy_curl.on_success.call(@easy_curl)
@@ -679,15 +680,15 @@ describe Feedjira::Feed do
679
680
  @headers = "HTTP/1.0 404 Not Found\r\nDate: Thu, 29 Jan 2009 03:55:24 GMT\r\nServer: Apache\r\nX-FB-Host: chi-write6\r\nLast-Modified: Wed, 28 Jan 2009 04:10:32 GMT\r\n"
680
681
  @body = 'Page could not be found.'
681
682
 
682
- @easy_curl.stub(:response_code).and_return(404)
683
- @easy_curl.stub(:header_str).and_return(@headers)
684
- @easy_curl.stub(:body_str).and_return(@body)
683
+ allow(@easy_curl).to receive(:response_code).and_return(404)
684
+ allow(@easy_curl).to receive(:header_str).and_return(@headers)
685
+ allow(@easy_curl).to receive(:body_str).and_return(@body)
685
686
  end
686
687
 
687
688
  it 'should call on success callback if the response code is 304' do
688
689
  success = lambda { |feed| }
689
- success.should_receive(:call).with(@feed)
690
- @easy_curl.should_receive(:response_code).and_return(304)
690
+ expect(success).to receive(:call).with(@feed)
691
+ expect(@easy_curl).to receive(:response_code).and_return(304)
691
692
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], {}, { :on_success => success })
692
693
  @easy_curl.on_redirect.call(@easy_curl)
693
694
  end
@@ -697,8 +698,8 @@ describe Feedjira::Feed do
697
698
  Feedjira::Feed.add_feed_to_multi(@multi, @feed, [], responses, {})
698
699
  @easy_curl.on_failure.call(@easy_curl)
699
700
 
700
- responses.length.should == 1
701
- responses[@paul_feed[:url]].should == 404
701
+ expect(responses.length).to eq 1
702
+ expect(responses[@paul_feed[:url]]).to eq 404
702
703
  end
703
704
  end
704
705
  end
@@ -707,7 +708,7 @@ describe Feedjira::Feed do
707
708
  it "passes options to multicurl" do
708
709
  options = { user_agent: '007' }
709
710
 
710
- Feedjira::Feed.should_receive(:add_url_to_multi).
711
+ expect(Feedjira::Feed).to receive(:add_url_to_multi).
711
712
  with(anything, anything, anything, anything, options)
712
713
 
713
714
  Feedjira::Feed.fetch_and_parse(sample_rss_feed, options)
@@ -720,36 +721,36 @@ describe Feedjira::Feed do
720
721
  end
721
722
 
722
723
  it 'should decode the response body using gzip if the Content-Encoding: is gzip' do
723
- @curl_easy.stub(:header_str).and_return('Content-Encoding: gzip')
724
+ allow(@curl_easy).to receive(:header_str).and_return('Content-Encoding: gzip')
724
725
  string_io = double('stringio', :read => @curl_easy.body_str, :close => true)
725
- StringIO.should_receive(:new).and_return(string_io)
726
- Zlib::GzipReader.should_receive(:new).with(string_io).and_return(string_io)
726
+ expect(StringIO).to receive(:new).and_return(string_io)
727
+ expect(Zlib::GzipReader).to receive(:new).with(string_io).and_return(string_io)
727
728
  Feedjira::Feed.decode_content(@curl_easy)
728
729
  end
729
730
 
730
731
  it 'should decode the response body using gzip if the Content-Encoding: is gzip even when the case is wrong' do
731
- @curl_easy.stub(:header_str).and_return('content-encoding: gzip')
732
+ allow(@curl_easy).to receive(:header_str).and_return('content-encoding: gzip')
732
733
  string_io = double('stringio', :read => @curl_easy.body_str, :close => true)
733
- StringIO.should_receive(:new).and_return(string_io)
734
- Zlib::GzipReader.should_receive(:new).with(string_io).and_return(string_io)
734
+ expect(StringIO).to receive(:new).and_return(string_io)
735
+ expect(Zlib::GzipReader).to receive(:new).with(string_io).and_return(string_io)
735
736
  Feedjira::Feed.decode_content(@curl_easy)
736
737
  end
737
738
 
738
739
  it 'should deflate the response body using inflate if the Content-Encoding: is deflate' do
739
- @curl_easy.stub(:header_str).and_return('Content-Encoding: deflate')
740
- Zlib::Inflate.should_receive(:inflate).with(@curl_easy.body_str)
740
+ allow(@curl_easy).to receive(:header_str).and_return('Content-Encoding: deflate')
741
+ expect(Zlib::Inflate).to receive(:inflate).with(@curl_easy.body_str)
741
742
  Feedjira::Feed.decode_content(@curl_easy)
742
743
  end
743
744
 
744
745
  it 'should deflate the response body using inflate if the Content-Encoding: is deflate event if the case is wrong' do
745
- @curl_easy.stub(:header_str).and_return('content-encoding: deflate')
746
- Zlib::Inflate.should_receive(:inflate).with(@curl_easy.body_str)
746
+ allow(@curl_easy).to receive(:header_str).and_return('content-encoding: deflate')
747
+ expect(Zlib::Inflate).to receive(:inflate).with(@curl_easy.body_str)
747
748
  Feedjira::Feed.decode_content(@curl_easy)
748
749
  end
749
750
 
750
751
  it 'should return the response body if it is not encoded' do
751
- @curl_easy.stub(:header_str).and_return('')
752
- Feedjira::Feed.decode_content(@curl_easy).should == '<xml></xml>'
752
+ allow(@curl_easy).to receive(:header_str).and_return('')
753
+ expect(Feedjira::Feed.decode_content(@curl_easy)).to eq '<xml></xml>'
753
754
  end
754
755
  end
755
756
 
@@ -757,7 +758,7 @@ describe Feedjira::Feed do
757
758
  it "passes options to multicurl" do
758
759
  options = { user_agent: '007' }
759
760
 
760
- Feedjira::Feed.should_receive(:add_feed_to_multi).
761
+ expect(Feedjira::Feed).to receive(:add_feed_to_multi).
761
762
  with(anything, anything, anything, anything, options)
762
763
 
763
764
  Feedjira::Feed.update([nil], options)