faraday-http-cache 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/json_spec.rb CHANGED
@@ -1,21 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Faraday::HttpCache do
4
- let(:logger) { double('a Logger object', :debug => nil) }
5
-
6
4
  let(:client) do
7
- Faraday.new(:url => ENV['FARADAY_SERVER']) do |stack|
8
- stack.response :json, :content_type => /\bjson$/
9
- stack.use :http_cache, :logger => logger
5
+ Faraday.new(url: ENV['FARADAY_SERVER']) do |stack|
6
+ stack.response :json, content_type: /\bjson$/
7
+ stack.use :http_cache
10
8
  adapter = ENV['FARADAY_ADAPTER']
11
9
  stack.headers['X-Faraday-Adapter'] = adapter
12
10
  stack.adapter adapter.to_sym
13
11
  end
14
12
  end
15
13
 
16
- it "works fine with other middlewares" do
14
+ it 'works fine with other middlewares' do
17
15
  client.get('clear')
18
- client.get('json').body['count'].should == 1
19
- client.get('json').body['count'].should == 1
16
+ expect(client.get('json').body['count']).to eq(1)
17
+ expect(client.get('json').body['count']).to eq(1)
20
18
  end
21
19
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Faraday::HttpCache do
4
- let(:logger) { double('a Logger object', :debug => nil) }
4
+ let(:logger) { double('a Logger object', debug: nil) }
5
5
 
6
6
  let(:client) do
7
- Faraday.new(:url => ENV['FARADAY_SERVER']) do |stack|
8
- stack.use Faraday::HttpCache, :logger => logger
7
+ Faraday.new(url: ENV['FARADAY_SERVER']) do |stack|
8
+ stack.use Faraday::HttpCache, logger: logger
9
9
  adapter = ENV['FARADAY_ADAPTER']
10
10
  stack.headers['X-Faraday-Adapter'] = adapter
11
11
  stack.adapter adapter.to_sym
@@ -16,154 +16,181 @@ describe Faraday::HttpCache do
16
16
  client.get('clear')
17
17
  end
18
18
 
19
- it "doesn't cache POST requests" do
19
+ it 'does not cache POST requests' do
20
20
  client.post('post').body
21
- client.post('post').body.should == "2"
21
+ expect(client.post('post').body).to eq('2')
22
22
  end
23
23
 
24
- it "logs that a POST request is unacceptable" do
25
- logger.should_receive(:debug).with('HTTP Cache: [POST /post] unacceptable')
24
+ it 'logs that a POST request is unacceptable' do
25
+ expect(logger).to receive(:debug).with('HTTP Cache: [POST /post] unacceptable')
26
26
  client.post('post').body
27
27
  end
28
28
 
29
- it "doesn't cache responses with invalid status code" do
29
+ it 'does not cache responses with invalid status code' do
30
30
  client.get('broken')
31
- client.get('broken').body.should == "2"
31
+ expect(client.get('broken').body).to eq('2')
32
32
  end
33
33
 
34
- it "logs that a response with a bad status code is invalid" do
35
- logger.should_receive(:debug).with('HTTP Cache: [GET /broken] miss, invalid')
34
+ it 'logs that a response with a bad status code is invalid' do
35
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /broken] miss, invalid')
36
36
  client.get('broken')
37
37
  end
38
38
 
39
- it "doesn't cache requests with a private cache control" do
39
+ it 'does not cache requests with a private cache control' do
40
40
  client.get('private')
41
- client.get('private').body.should == "2"
41
+ expect(client.get('private').body).to eq('2')
42
42
  end
43
43
 
44
- it "logs that a private response is invalid" do
45
- logger.should_receive(:debug).with('HTTP Cache: [GET /private] miss, invalid')
44
+ it 'logs that a private response is invalid' do
45
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /private] miss, invalid')
46
46
  client.get('private')
47
47
  end
48
48
 
49
- it "doesn't cache requests with a explicit no-store directive" do
49
+ it 'does not cache requests with a explicit no-store directive' do
50
50
  client.get('dontstore')
51
- client.get('dontstore').body.should == "2"
51
+ expect(client.get('dontstore').body).to eq('2')
52
52
  end
53
53
 
54
- it "logs that a response with a no-store directive is invalid" do
55
- logger.should_receive(:debug).with('HTTP Cache: [GET /dontstore] miss, invalid')
54
+ it 'logs that a response with a no-store directive is invalid' do
55
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /dontstore] miss, invalid')
56
56
  client.get('dontstore')
57
57
  end
58
58
 
59
- it "caches multiple responses when the headers differ" do
59
+ it 'caches multiple responses when the headers differ' do
60
60
  client.get('get', nil, 'HTTP_ACCEPT' => 'text/html')
61
- client.get('get', nil, 'HTTP_ACCEPT' => 'text/html').body.should == "1"
62
-
63
- client.get('get', nil, 'HTTP_ACCEPT' => 'application/json').body.should == "2"
61
+ expect(client.get('get', nil, 'HTTP_ACCEPT' => 'text/html').body).to eq('1')
62
+ expect(client.get('get', nil, 'HTTP_ACCEPT' => 'application/json').body).to eq('2')
64
63
  end
65
64
 
66
- it "caches requests with the 'Expires' header" do
65
+ it 'caches requests with the "Expires" header' do
67
66
  client.get('expires')
68
- client.get('expires').body.should == "1"
67
+ expect(client.get('expires').body).to eq('1')
69
68
  end
70
69
 
71
- it "logs that a request with the 'Expires' is fresh and stored" do
72
- logger.should_receive(:debug).with('HTTP Cache: [GET /expires] miss, store')
70
+ it 'logs that a request with the "Expires" is fresh and stored' do
71
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /expires] miss, store')
73
72
  client.get('expires')
74
73
  end
75
74
 
76
- it "caches GET responses" do
75
+ it 'caches GET responses' do
77
76
  client.get('get')
78
- client.get('get').body.should == "1"
77
+ expect(client.get('get').body).to eq('1')
79
78
  end
80
79
 
81
- it "logs that a GET response is stored" do
82
- logger.should_receive(:debug).with('HTTP Cache: [GET /get] miss, store')
80
+ it 'logs that a GET response is stored' do
81
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /get] miss, store')
83
82
  client.get('get')
84
83
  end
85
84
 
86
- it "differs requests with different query strings in the log" do
87
- logger.should_receive(:debug).with('HTTP Cache: [GET /get] miss, store')
88
- logger.should_receive(:debug).with('HTTP Cache: [GET /get?q=what] miss, store')
85
+ it 'differs requests with different query strings in the log' do
86
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /get] miss, store')
87
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /get?q=what] miss, store')
89
88
  client.get('get')
90
- client.get('get', :q => "what")
89
+ client.get('get', q: 'what')
91
90
  end
92
91
 
93
- it "logs that a stored GET response is fresh" do
92
+ it 'logs that a stored GET response is fresh' do
94
93
  client.get('get')
95
- logger.should_receive(:debug).with('HTTP Cache: [GET /get] fresh')
94
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /get] fresh')
96
95
  client.get('get')
97
96
  end
98
97
 
99
- it "sends the 'Last-Modified' header on response validation" do
98
+ it 'sends the "Last-Modified" header on response validation' do
100
99
  client.get('timestamped')
101
- client.get('timestamped').body.should == "1"
100
+ expect(client.get('timestamped').body).to eq('1')
102
101
  end
103
102
 
104
- it "logs that the request with 'Last-Modified' was revalidated" do
103
+ it 'logs that the request with "Last-Modified" was revalidated' do
105
104
  client.get('timestamped')
106
- logger.should_receive(:debug).with('HTTP Cache: [GET /timestamped] valid, store')
107
- client.get('timestamped').body.should == "1"
105
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /timestamped] valid, store')
106
+ expect(client.get('timestamped').body).to eq('1')
108
107
  end
109
108
 
110
- it "sends the 'If-None-Match' header on response validation" do
109
+ it 'sends the "If-None-Match" header on response validation' do
111
110
  client.get('etag')
112
- client.get('etag').body.should == "1"
111
+ expect(client.get('etag').body).to eq('1')
113
112
  end
114
113
 
115
- it "logs that the request with 'ETag' was revalidated" do
114
+ it 'logs that the request with "ETag" was revalidated' do
116
115
  client.get('etag')
117
- logger.should_receive(:debug).with('HTTP Cache: [GET /etag] valid, store')
118
- client.get('etag').body.should == "1"
116
+ expect(logger).to receive(:debug).with('HTTP Cache: [GET /etag] valid, store')
117
+ expect(client.get('etag').body).to eq('1')
119
118
  end
120
119
 
121
- it "maintains the 'Date' header for cached responses" do
122
- date = client.get('get').headers['Date']
123
- client.get('get').headers['Date'].should == date
120
+ it 'maintains the "Date" header for cached responses' do
121
+ first_date = client.get('get').headers['Date']
122
+ second_date = client.get('get').headers['Date']
123
+ expect(first_date).to eq(second_date)
124
124
  end
125
125
 
126
- it "preserves an old 'Date' header if present" do
126
+ it 'preserves an old "Date" header if present' do
127
127
  date = client.get('yesterday').headers['Date']
128
- date.should =~ /^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/
128
+ expect(date).to match(/^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/)
129
129
  end
130
130
 
131
- it "updates the 'Cache-Control' header when a response is validated" do
132
- cache_control = client.get('etag').headers['Cache-Control']
133
- client.get('etag').headers['Cache-Control'].should_not == cache_control
131
+ it 'updates the "Cache-Control" header when a response is validated' do
132
+ first_cache_control = client.get('etag').headers['Cache-Control']
133
+ second_cache_control = client.get('etag').headers['Cache-Control']
134
+ expect(first_cache_control).not_to eql(second_cache_control)
134
135
  end
135
136
 
136
- it "updates the 'Date' header when a response is validated" do
137
- date = client.get('etag').headers['Date']
138
- client.get('etag').headers['Date'].should_not == date
137
+ it 'updates the "Date" header when a response is validated' do
138
+ first_date = client.get('etag').headers['Date']
139
+ second_date = client.get('etag').headers['Date']
140
+ expect(first_date).not_to eql(second_date)
139
141
  end
140
142
 
141
- it "updates the 'Expires' header when a response is validated" do
142
- expires = client.get('etag').headers['Expires']
143
- client.get('etag').headers['Expires'].should_not == expires
143
+ it 'updates the "Expires" header when a response is validated' do
144
+ first_expires = client.get('etag').headers['Expires']
145
+ second_expires = client.get('etag').headers['Expires']
146
+ expect(first_expires).not_to eql(second_expires)
144
147
  end
145
-
146
- it "updates the 'Vary' header when a response is validated" do
147
- vary = client.get('etag').headers['Vary']
148
- client.get('etag').headers['Vary'].should_not == vary
148
+
149
+ it 'updates the "Vary" header when a response is validated' do
150
+ first_vary = client.get('etag').headers['Vary']
151
+ second_vary = client.get('etag').headers['Vary']
152
+ expect(first_vary).not_to eql(second_vary)
149
153
  end
150
154
 
151
155
  describe 'Configuration options' do
152
- let(:app) { double("it's an app!") }
156
+ let(:app) { double('it is an app!') }
153
157
 
154
158
  it 'uses the options to create a Cache Store' do
155
- ActiveSupport::Cache.should_receive(:lookup_store).with(:file_store, ['tmp'])
156
- Faraday::HttpCache.new(app, :file_store, 'tmp')
159
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:file_store, ['tmp'])
160
+ Faraday::HttpCache.new(app, store: :file_store, store_options: ['tmp'])
157
161
  end
158
162
 
159
163
  it 'accepts a Hash option' do
160
- ActiveSupport::Cache.should_receive(:lookup_store).with(:memory_store, { :size => 1024 })
161
- Faraday::HttpCache.new(app, :memory_store, :size => 1024)
164
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:memory_store, [{ size: 1024 }])
165
+ Faraday::HttpCache.new(app, store: :memory_store, store_options: [size: 1024])
166
+ end
167
+
168
+ it 'consumes the "logger" key' do
169
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:memory_store, nil)
170
+ Faraday::HttpCache.new(app, store: :memory_store, logger: logger)
162
171
  end
163
172
 
164
- it "consumes the 'logger' key" do
165
- ActiveSupport::Cache.should_receive(:lookup_store).with(:memory_store, {})
166
- Faraday::HttpCache.new(app, :memory_store, :logger => logger)
173
+ context 'with deprecated options format' do
174
+ it 'uses the options to create a Cache Store' do
175
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:file_store, ['tmp'])
176
+ Faraday::HttpCache.new(app, :file_store, 'tmp')
177
+ end
178
+
179
+ it 'accepts a Hash option' do
180
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:memory_store, [{ size: 1024 }])
181
+ Faraday::HttpCache.new(app, :memory_store, size: 1024)
182
+ end
183
+
184
+ it 'consumes the "logger" key' do
185
+ expect(ActiveSupport::Cache).to receive(:lookup_store).with(:memory_store, [{}])
186
+ Faraday::HttpCache.new(app, :memory_store, logger: logger)
187
+ end
188
+
189
+ it 'warns the user about the deprecated options' do
190
+ expect(ActiveSupport::Deprecation).to receive(:warn)
191
+
192
+ Faraday::HttpCache.new(app, :memory_store, logger: logger)
193
+ end
167
194
  end
168
195
  end
169
196
  end
@@ -1,156 +1,157 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Faraday::HttpCache::Response do
4
- describe "cacheable?" do
5
- it "the response isn't cacheable if the response is marked as private" do
6
- headers = { "Cache-Control" => "private" }
7
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
4
+ describe 'cacheable?' do
5
+ it 'the response is not cacheable if the response is marked as private' do
6
+ headers = { 'Cache-Control' => 'private' }
7
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
8
8
 
9
- response.should_not be_cacheable
9
+ expect(response).not_to be_cacheable
10
10
  end
11
11
 
12
- it "the response isn't cacheable if it shouldn't be stored" do
13
- headers = { "Cache-Control" => "no-store" }
14
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
12
+ it 'the response is not cacheable if it should not be stored' do
13
+ headers = { 'Cache-Control' => 'no-store' }
14
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
15
15
 
16
- response.should_not be_cacheable
16
+ expect(response).not_to be_cacheable
17
17
  end
18
18
 
19
- it "the response isn't cacheable when the status code isn't acceptable" do
20
- headers = { "Cache-Control" => "max-age=400" }
21
- response = Faraday::HttpCache::Response.new(:status => 503, :response_headers => headers)
22
- response.should_not be_cacheable
19
+ it 'the response is not cacheable when the status code is not acceptable' do
20
+ headers = { 'Cache-Control' => 'max-age=400' }
21
+ response = Faraday::HttpCache::Response.new(status: 503, response_headers: headers)
22
+ expect(response).not_to be_cacheable
23
23
  end
24
24
 
25
25
  [200, 203, 300, 301, 302, 404, 410].each do |status|
26
26
  it "the response is cacheable if the status code is #{status} and the response is fresh" do
27
- headers = { "Cache-Control" => "max-age=400" }
28
- response = Faraday::HttpCache::Response.new(:status => status, :response_headers => headers)
27
+ headers = { 'Cache-Control' => 'max-age=400' }
28
+ response = Faraday::HttpCache::Response.new(status: status, response_headers: headers)
29
29
 
30
- response.should be_cacheable
30
+ expect(response).to be_cacheable
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
- describe "freshness" do
36
- it "is fresh if the response still has some time to live" do
35
+ describe 'freshness' do
36
+ it 'is fresh if the response still has some time to live' do
37
37
  date = 200.seconds.ago.httpdate
38
- headers = { "Cache-Control" => "max-age=400", 'Date' => date }
39
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
38
+ headers = { 'Cache-Control' => 'max-age=400', 'Date' => date }
39
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
40
40
 
41
- response.should be_fresh
41
+ expect(response).to be_fresh
42
42
  end
43
43
 
44
- it "isn't fresh when the ttl has expired" do
44
+ it 'is not fresh when the ttl has expired' do
45
45
  date = 500.seconds.ago.httpdate
46
- headers = { "Cache-Control" => "max-age=400", 'Date' => date }
47
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
46
+ headers = { 'Cache-Control' => 'max-age=400', 'Date' => date }
47
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
48
48
 
49
- response.should_not be_fresh
49
+ expect(response).not_to be_fresh
50
50
  end
51
51
  end
52
52
 
53
- it "sets the 'Date' header if isn't present" do
53
+ it 'sets the "Date" header if is not present' do
54
54
  headers = { 'Date' => nil }
55
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
55
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
56
56
 
57
- response.date.should be_present
57
+ expect(response.date).to be
58
58
  end
59
59
 
60
- it "the response is not modified if the status code is 304" do
61
- response = Faraday::HttpCache::Response.new(:status => 304)
62
- response.should be_not_modified
60
+ it 'the response is not modified if the status code is 304' do
61
+ response = Faraday::HttpCache::Response.new(status: 304)
62
+ expect(response).to be_not_modified
63
63
  end
64
64
 
65
- it "returns the 'Last-Modified' header on the #last_modified method" do
66
- headers = { "Last-Modified" => "123"}
67
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
68
- response.last_modified.should == "123"
65
+ it 'returns the "Last-Modified" header on the #last_modified method' do
66
+ headers = { 'Last-Modified' => '123' }
67
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
68
+ expect(response.last_modified).to eq('123')
69
69
  end
70
70
 
71
- it "returns the 'ETag' header on the #etag method" do
72
- headers = { "ETag" => "tag"}
73
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
74
- response.etag.should == "tag"
71
+ it 'returns the "ETag" header on the #etag method' do
72
+ headers = { 'ETag' => 'tag' }
73
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
74
+ expect(response.etag).to eq('tag')
75
75
  end
76
76
 
77
- describe "max age calculation" do
78
- it "uses the shared max age directive when present" do
79
- headers = { "Cache-Control" => "s-maxage=200, max-age=0"}
80
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
81
- response.max_age.should == 200
77
+ describe 'max age calculation' do
78
+ it 'uses the shared max age directive when present' do
79
+ headers = { 'Cache-Control' => 's-maxage=200, max-age=0' }
80
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
81
+ expect(response.max_age).to be(200)
82
82
  end
83
83
 
84
- it "uses the max age directive when present" do
85
- headers = { "Cache-Control" => "max-age=200"}
86
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
87
- response.max_age.should == 200
84
+ it 'uses the max age directive when present' do
85
+ headers = { 'Cache-Control' => 'max-age=200' }
86
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
87
+ expect(response.max_age).to be(200)
88
88
  end
89
89
 
90
- it "fallsback to the expiration date leftovers" do
91
- headers = { "Expires" => (Time.now + 100).httpdate, 'Date' => Time.now.httpdate }
92
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
93
- response.max_age.should < 100
94
- response.max_age.should > 98
90
+ it 'fallsback to the expiration date leftovers' do
91
+ headers = { 'Expires' => (Time.now + 100).httpdate, 'Date' => Time.now.httpdate }
92
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
93
+
94
+ expect(response.max_age).to be < 100
95
+ expect(response.max_age).to be > 98
95
96
  end
96
97
 
97
- it "returns nil when there's no information to calculate the max age" do
98
+ it 'returns nil when there is no information to calculate the max age' do
98
99
  response = Faraday::HttpCache::Response.new
99
- response.max_age.should be_nil
100
+ expect(response.max_age).to be_nil
100
101
  end
101
102
  end
102
103
 
103
- describe "age calculation" do
104
- it "uses the 'Age' header if it's present" do
105
- response = Faraday::HttpCache::Response.new(:response_headers => { "Age" => "3" })
106
- response.age.should == 3
104
+ describe 'age calculation' do
105
+ it 'uses the "Age" header if it is present' do
106
+ response = Faraday::HttpCache::Response.new(response_headers: { 'Age' => '3' })
107
+ expect(response.age).to eq(3)
107
108
  end
108
109
 
109
- it "calculates the time from the 'Date' header" do
110
+ it 'calculates the time from the "Date" header' do
110
111
  date = 3.seconds.ago.httpdate
111
- response = Faraday::HttpCache::Response.new(:response_headers => { 'Date' => date })
112
- response.age.should == 3
112
+ response = Faraday::HttpCache::Response.new(response_headers: { 'Date' => date })
113
+ expect(response.age).to eq(3)
113
114
  end
114
115
 
115
- it "returns 0 if there's no 'Age' or 'Date' header present" do
116
- response = Faraday::HttpCache::Response.new(:response_headers => {})
117
- response.age.should == 0
116
+ it 'returns 0 if there is no "Age" or "Date" header present' do
117
+ response = Faraday::HttpCache::Response.new(response_headers: {})
118
+ expect(response.age).to eq(0)
118
119
  end
119
120
  end
120
121
 
121
- describe "time to live calculation" do
122
- it "returns the time to live based on the max age limit" do
122
+ describe 'time to live calculation' do
123
+ it 'returns the time to live based on the max age limit' do
123
124
  date = 200.seconds.ago.httpdate
124
- headers = { "Cache-Control" => "max-age=400", 'Date' => date }
125
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
126
- response.ttl.should == 200
125
+ headers = { 'Cache-Control' => 'max-age=400', 'Date' => date }
126
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
127
+ expect(response.ttl).to eq(200)
127
128
  end
128
129
  end
129
130
 
130
- describe "response unboxing" do
131
- subject { described_class.new(:status => 200, :response_headers => {}, :body => "Hi!") }
131
+ describe 'response unboxing' do
132
+ subject { described_class.new(status: 200, response_headers: {}, body: 'Hi!') }
132
133
 
133
- let(:env) { { :method => :get } }
134
+ let(:env) { { method: :get } }
134
135
  let(:response) { subject.to_response(env) }
135
136
 
136
- it "merges the supplied env object with the response data" do
137
- response.env[:method].should be
137
+ it 'merges the supplied env object with the response data' do
138
+ expect(response.env[:method]).to be
138
139
  end
139
140
 
140
- it "returns a Faraday::Response" do
141
- response.should be_a Faraday::Response
141
+ it 'returns a Faraday::Response' do
142
+ expect(response).to be_a(Faraday::Response)
142
143
  end
143
144
 
144
- it "merges the status code" do
145
- response.status.should == 200
145
+ it 'merges the status code' do
146
+ expect(response.status).to eq(200)
146
147
  end
147
148
 
148
- it "merges the headers" do
149
- response.headers.should be_a Faraday::Utils::Headers
149
+ it 'merges the headers' do
150
+ expect(response.headers).to be_a(Faraday::Utils::Headers)
150
151
  end
151
152
 
152
- it "merges the body" do
153
- response.body.should == "Hi!"
153
+ it 'merges the body' do
154
+ expect(response.body).to eq('Hi!')
154
155
  end
155
156
  end
156
157
 
@@ -163,13 +164,12 @@ describe Faraday::HttpCache::Response do
163
164
  'Expires' => 37.seconds.from_now.httpdate,
164
165
  'Last-Modified' => 300.seconds.ago.httpdate
165
166
  }
166
- response = Faraday::HttpCache::Response.new(:response_headers => headers)
167
- response.should be_fresh
167
+ response = Faraday::HttpCache::Response.new(response_headers: headers)
168
+ expect(response).to be_fresh
168
169
 
169
170
  response.serializable_hash
170
- response.max_age.should == 34
171
- response.should_not be_fresh
171
+ expect(response.max_age).to eq(34)
172
+ expect(response).not_to be_fresh
172
173
  end
173
174
  end
174
-
175
175
  end