Permalink
Browse files

Refactoring: extract private method.

  • Loading branch information...
1 parent c9d9bca commit 44acf01ed4a10b6b32543f53f610a32619ce9bca @myronmarston committed Jan 22, 2011
Showing with 11 additions and 10 deletions.
  1. +11 −10 lib/vcr.rb
View
@@ -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
@@ -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

0 comments on commit 44acf01

Please sign in to comment.