Skip to content

Commit 95a9192

Browse files
authored
Allow usage of typhoeus >= 1.2 (#1023)
* Allow usage of typhoeus >= 1.2 * Add Content-Type to be make request compatible with newer rack/sinatra
1 parent cde8934 commit 95a9192

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ gem "rspec", "~> 3.0"
2727
gem "sinatra"
2828
gem "test-unit", "~> 3.4.4"
2929
gem "timecop"
30-
gem "typhoeus", "~> 1.1.0"
30+
gem "typhoeus", ">= 1.1.0"
3131
gem "webmock"
3232
gem "webrick"
3333
gem "yard"

spec/lib/vcr/library_hooks/typhoeus_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ def get_response
9292
end
9393

9494
context 'when a request is made with a hash for the POST body' do
95+
let(:body) { { foo: "17" }.to_json }
96+
9597
def make_request
9698
VCR.use_cassette("hash_body") do
9799
Typhoeus::Request.post(
98100
"http://localhost:#{VCR::SinatraApp.port}/return-request-body",
99-
:body => { :foo => "17" }
101+
headers: {'Content-Type'=> "application/json"},
102+
body: body
100103
)
101104
end
102105
end
@@ -105,7 +108,7 @@ def make_request
105108
recorded = make_request
106109
played_back = make_request
107110

108-
expect(recorded.body).to eq("foo=17")
111+
expect(recorded.body).to eq(body)
109112
expect(played_back.body).to eq(recorded.body)
110113
end
111114
end
@@ -121,10 +124,10 @@ def on_headers(&callback)
121124

122125
it { expect(request.tap { |r| r.on_headers {} }).not_to be_streaming }
123126

124-
it { expect { |b| on_headers(&b) }.to yield_with_args(have_attributes(headers: include('Content-Length' => '18'))) }
127+
it { expect { |b| on_headers(&b) }.to yield_with_args(have_attributes(headers: hash_including('Content-Length' => '18'))) }
125128
it { expect { |b| on_headers(&b) }.to yield_with_args(have_attributes(headers: match_array(on_headers.headers))) }
126129

127-
it { expect(on_headers).to have_attributes(headers: include("Content-Length" => "18")) }
130+
it { expect(on_headers).to have_attributes(headers: hash_including("Content-Length" => "18")) }
128131
it { expect(on_headers).to have_attributes(headers: match_array(on_headers.headers)) }
129132
end
130133

0 commit comments

Comments
 (0)