spec/vcr/library_hooks/fakeweb_spec.rb in vcr-2.0.0.rc1 vs spec/vcr/library_hooks/fakeweb_spec.rb in vcr-2.0.0.rc2
- old
+ new
@@ -27,29 +27,24 @@
# assert that we are cleaning up the global state after every request
VCR::LibraryHooks::FakeWeb::RequestHandler.already_seen_requests.to_a.should eq([])
end
end
- it_performs('version checking', 'FakeWeb',
- :valid => %w[ 1.3.0 1.3.1 1.3.99 ],
- :too_low => %w[ 1.2.8 1.1.30 0.30.30 ],
- :too_high => %w[ 1.4.0 1.10.0 2.0.0 ]
- ) do
- before(:each) { @orig_version = FakeWeb::VERSION }
- after(:each) { FakeWeb::VERSION = @orig_version }
-
- # Cannot be regular method def as that raises a "dynamic constant assignment" error
- define_method :stub_version do |version|
- FakeWeb::VERSION = version
- end
- end
-
describe "some specific Net::HTTP edge cases" do
before(:each) do
VCR.stub(:real_http_connections_allowed? => true)
end
+ it 'records the request body when using #post_form' do
+ VCR.should_receive(:record_http_interaction) do |interaction|
+ interaction.request.body.should 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|
interaction.request.headers.should_not have_key('content-type')
interaction.request.headers.should_not have_key('host')
end
@@ -100,17 +95,13 @@
ignored_body.should_not eq(recorded_body)
ignored_body.should match(/Response \d+/)
end
end
- describe "VCR.configuration.after_library_hooks_loaded hook", :disable_warnings do
- before(:each) do
- load "vcr/library_hooks/fakeweb.rb" # to re-add the hook since it's cleared by each test
- end
+ describe "VCR.configuration.after_library_hooks_loaded hook" do
+ let(:run_hook) { $fakeweb_after_loaded_hook.conditionally_invoke }
- let(:run_hook) { VCR.configuration.invoke_hook(:after_library_hooks_loaded) }
-
context 'when WebMock has been loaded' do
before(:each) { defined?(WebMock).should be_true }
it 'raises an error since FakeWeb and WebMock cannot both be used simultaneously' do
expect { run_hook }.to raise_error(ArgumentError, /cannot use both/)
@@ -131,10 +122,10 @@
describe "when a SocketError occurs" do
before(:each) do
VCR.configuration.ignore_request { |r| true }
end
- it_behaves_like "request hooks", :fakeweb do
+ it_behaves_like "request hooks", :fakeweb, :ignored do
undef assert_expected_response
def assert_expected_response(response)
response.should be_nil
end