Skip to content

Commit

Permalink
Refactoring: extract private method.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Jan 22, 2011
1 parent c9d9bca commit 44acf01
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/vcr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,7 @@ def http_stubbing_adapter
raise ArgumentError.new("You have configured VCR to use both :fakeweb and :webmock. You cannot use both.")
end

adapters = VCR::Config.http_stubbing_libraries.map do |lib|
case lib
when :fakeweb; HttpStubbingAdapters::FakeWeb
when :webmock; HttpStubbingAdapters::WebMock
when :typhoeus; HttpStubbingAdapters::Typhoeus
when :faraday; HttpStubbingAdapters::Faraday
else raise ArgumentError.new("#{lib.inspect} is not a supported HTTP stubbing library.")
end
end

adapters = VCR::Config.http_stubbing_libraries.map { |l| adapter_for(l) }
raise ArgumentError.new("The http stubbing library is not configured.") if adapters.empty?
HttpStubbingAdapters::MultiObjectProxy.for(*adapters)
end
Expand Down Expand Up @@ -132,6 +123,16 @@ def turned_on?

private

def adapter_for(lib)
case lib
when :fakeweb; HttpStubbingAdapters::FakeWeb
when :webmock; HttpStubbingAdapters::WebMock
when :typhoeus; HttpStubbingAdapters::Typhoeus
when :faraday; HttpStubbingAdapters::Faraday
else raise ArgumentError.new("#{lib.inspect} is not a supported HTTP stubbing library.")
end
end

def cassettes
@cassettes ||= []
end
Expand Down

0 comments on commit 44acf01

Please sign in to comment.