Skip to content

Commit

Permalink
Remove MultiObjectProxy since it's no longer needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Oct 2, 2011
1 parent 05cf757 commit cae04f3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 209 deletions.
11 changes: 5 additions & 6 deletions lib/vcr.rb
Expand Up @@ -91,25 +91,24 @@ def configuration

def configure
yield configuration
http_stubbing_adapter # to force it to load. TODO: find a better way...
http_stubbing_adapters # to force it to load. TODO: find a better way...
end

def cucumber_tags(&block)
main_object = eval('self', block.binding)
yield VCR::CucumberTags.new(main_object)
end

def http_stubbing_adapter
@http_stubbing_adapter ||= begin
def http_stubbing_adapters
@http_stubbing_adapters ||= begin
if [:fakeweb, :webmock].all? { |l| VCR.configuration.http_stubbing_libraries.include?(l) }
raise ArgumentError.new("You have configured VCR to use both :fakeweb and :webmock. You cannot use both.")
end

adapters = VCR.configuration.http_stubbing_libraries.map { |l| adapter_for(l) }
raise ArgumentError.new("The http stubbing library is not configured.") if adapters.empty?
adapter = HttpStubbingAdapters::MultiObjectProxy.for(*adapters)
adapter.after_adapters_loaded
adapter
adapters.each { |a| a.after_adapters_loaded }
adapters
end
end

Expand Down
43 changes: 0 additions & 43 deletions lib/vcr/http_stubbing_adapters/multi_object_proxy.rb

This file was deleted.

43 changes: 0 additions & 43 deletions lib/vcr/util/basic_object.rb

This file was deleted.

Expand Up @@ -2,7 +2,6 @@
supported_http_libraries = args.shift
other = args

before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
subject { described_class }

describe '.exclusively_enabled' do
Expand Down
99 changes: 0 additions & 99 deletions spec/vcr/http_stubbing_adapters/multi_object_proxy_spec.rb

This file was deleted.

32 changes: 15 additions & 17 deletions spec/vcr_spec.rb
Expand Up @@ -180,54 +180,52 @@ def insert_cassette(name = :cassette_test)
end
end

describe '.http_stubbing_adapter' do
subject { VCR.http_stubbing_adapter }
before(:each) do
VCR.instance_variable_set(:@http_stubbing_adapter, nil)
end
describe '.http_stubbing_adapters' do
subject { VCR.http_stubbing_adapters }

it 'returns a multi object proxy for the configured stubbing libraries when multiple libs are configured', :unless => RUBY_PLATFORM == 'java' do
VCR.configuration.stub_with :fakeweb, :typhoeus
VCR.http_stubbing_adapter.proxied_objects.should eq([
it 'loads multiple stubbing adapters when configured with multiple' do
VCR.configuration.stub_with :fakeweb, :excon
VCR.http_stubbing_adapters.should =~ [
VCR::HttpStubbingAdapters::FakeWeb,
VCR::HttpStubbingAdapters::Typhoeus
])
VCR::HttpStubbingAdapters::Excon
]
end

{
:fakeweb => VCR::HttpStubbingAdapters::FakeWeb,
:webmock => VCR::HttpStubbingAdapters::WebMock,
:faraday => VCR::HttpStubbingAdapters::Faraday,
:excon => VCR::HttpStubbingAdapters::Excon
:excon => VCR::HttpStubbingAdapters::Excon,
:faraday => VCR::HttpStubbingAdapters::Faraday
}.each do |symbol, klass|
it "returns #{klass} for :#{symbol}" do
VCR.configuration.stub_with symbol
VCR.http_stubbing_adapter.should eq(klass)
VCR.http_stubbing_adapters.should eq([klass])
end
end

it 'calls #after_adapters_loaded on the configured stubbing adapter' do
it 'calls #after_adapters_loaded on the configured stubbing adapters' do
VCR::HttpStubbingAdapters::FakeWeb.should_receive(:after_adapters_loaded)
VCR.configuration.stub_with :fakeweb
VCR.http_stubbing_adapter
VCR.http_stubbing_adapters
end

it 'raises an error if both :fakeweb and :webmock are configured' do
VCR.configuration.stub_with :fakeweb, :webmock

expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /cannot use both/)
expect { VCR.http_stubbing_adapters }.to raise_error(ArgumentError, /cannot use both/)
end

it 'raises an error for unsupported stubbing libraries' do
VCR.configuration.stub_with :unsupported_library

expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /unsupported_library is not a supported HTTP stubbing library/i)
expect { VCR.http_stubbing_adapters }.to raise_error(ArgumentError, /unsupported_library is not a supported HTTP stubbing library/i)
end

it 'raises an error when no stubbing libraries are configured' do
VCR.configuration.stub_with

expect { VCR.http_stubbing_adapter }.to raise_error(ArgumentError, /the http stubbing library is not configured/i)
expect { VCR.http_stubbing_adapters }.to raise_error(ArgumentError, /the http stubbing library is not configured/i)
end
end

Expand Down

0 comments on commit cae04f3

Please sign in to comment.