spec/vcr/library_hooks/fakeweb_spec.rb in vcr-2.5.0 vs spec/vcr/library_hooks/fakeweb_spec.rb in vcr-2.6.0
- old
+ new
@@ -20,32 +20,32 @@
it_behaves_like 'a hook into an HTTP library', :fakeweb, 'net/http'
describe "some specific Net::HTTP edge cases" do
before(:each) do
- VCR.stub(:real_http_connections_allowed? => true)
+ allow(VCR).to receive(:real_http_connections_allowed?).and_return(true)
end
it 'records the request body when using #post_form' do
- VCR.should_receive(:record_http_interaction) do |interaction|
+ expect(VCR).to receive(:record_http_interaction) do |interaction|
expect(interaction.request.body).to eq("q=ruby")
end
uri = URI("http://localhost:#{VCR::SinatraApp.port}/foo")
Net::HTTP.post_form(uri, 'q' => 'ruby')
end
it "does not record headers for which Net::HTTP sets defaults near the end of the real request" do
- VCR.should_receive(:record_http_interaction) do |interaction|
+ expect(VCR).to receive(:record_http_interaction) do |interaction|
expect(interaction.request.headers).not_to have_key('content-type')
expect(interaction.request.headers).not_to have_key('host')
end
Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'x-http-user' => 'me' })
end
it "records headers for which Net::HTTP usually sets defaults when the user manually sets their values" do
- VCR.should_receive(:record_http_interaction) do |interaction|
+ expect(VCR).to receive(:record_http_interaction) do |interaction|
expect(interaction.request.headers['content-type']).to eq(['foo/bar'])
expect(interaction.request.headers['host']).to eq(['my-example.com'])
end
Net::HTTP.new('localhost', VCR::SinatraApp.port).send_request('POST', '/', '', { 'Content-Type' => 'foo/bar', 'Host' => 'my-example.com' })
end
@@ -55,20 +55,20 @@
return response
end
end
it 'records the interaction when Net::HTTP#request is called with a block with a return statement' do
- VCR.should_receive(:record_http_interaction).once
+ expect(VCR).to receive(:record_http_interaction).once
expect(perform_get_with_returning_block.body).to eq("GET to root")
end
def make_post_request
Net::HTTP.new('localhost', VCR::SinatraApp.port).post('/record-and-playback', '')
end
it 'records the interaction only once, even when Net::HTTP internally recursively calls #request' do
- VCR.should_receive(:record_http_interaction).once
+ expect(VCR).to receive(:record_http_interaction).once
make_post_request
end
it 'properly returns the response body for a post request when recording, stubbing or ignoring the request' do
recorded_body = nil
@@ -127,11 +127,11 @@
it 'does not raise an error' do
run_hook # should not raise an error
end
it "warns about FakeWeb deprecation" do
- ::Kernel.should_receive(:warn).with("WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 3.0.")
+ expect(::Kernel).to receive(:warn).with("WARNING: VCR's FakeWeb integration is deprecated and will be removed in VCR 3.0.")
run_hook
end
end
end
@@ -146,10 +146,10 @@
expect(response).to be_nil
end
undef make_request
def make_request(disabled = false)
- ::Net::HTTP.any_instance.stub(:request_without_vcr).and_raise(SocketError)
+ allow_any_instance_of(::Net::HTTP).to receive(:request_without_vcr).and_raise(SocketError)
expect {
::Net::HTTP.get_response(URI(request_url))
}.to raise_error(SocketError)
end
end