Permalink
Browse files

Update to latest typhoeus. No more need to monkey patch it!

  • Loading branch information...
1 parent f95ec75 commit 46c3be819a8607c9f5e3788bf82a9cc1265efbe4 @myronmarston committed Oct 19, 2011
Showing with 13 additions and 27 deletions.
  1. +2 −0 CHANGELOG.md
  2. +1 −1 Gemfile
  3. +6 −22 lib/vcr/library_hooks/typhoeus.rb
  4. +3 −3 spec/vcr/library_hooks/typhoeus_spec.rb
  5. +1 −1 vcr.gemspec
View
@@ -4,6 +4,8 @@
## 2.0.0 Beta 1 (October 8, 2011)
+* Update to (and require) Typhoeus 0.3.2.
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.11.3...v2.0.0.beta1)
### Changed
View
@@ -7,7 +7,7 @@ group :development do
gem 'patron', '~> 0.4.15'
gem 'em-http-request', '~> 0.3.0'
gem 'curb', '~> 0.7.15'
- gem 'typhoeus', '~> 0.2.1'
+ gem 'typhoeus', '~> 0.3.2'
end
platforms :jruby do
@@ -2,7 +2,7 @@
require 'vcr/request_handler'
require 'typhoeus'
-VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.2.1', '0.2').check_version!
+VCR::VersionChecker.new('Typhoeus', Typhoeus::VERSION, '0.3.2', '0.3').check_version!
module VCR
class LibraryHooks
@@ -35,29 +35,19 @@ def initialize(request)
private
- def on_stubbed_request
- hydra_mock
- end
-
def vcr_request
@vcr_request ||= vcr_request_from(request)
end
- def typhoeus_response
- @typhoeus_response ||= ::Typhoeus::Response.new \
+ def on_stubbed_request
+ ::Typhoeus::Response.new \
:http_version => stubbed_response.http_version,
:code => stubbed_response.status.code,
:status_message => stubbed_response.status.message,
:headers_hash => stubbed_response_headers,
:body => stubbed_response.body
end
- def hydra_mock
- @hydra_mock ||= ::Typhoeus::HydraMock.new(/.*/, :any).tap do |m|
- m.and_return(typhoeus_response)
- end
- end
-
def stubbed_response_headers
@stubbed_response_headers ||= {}.tap do |hash|
stubbed_response.headers.each do |key, values|
@@ -75,19 +65,13 @@ def stubbed_response_headers
end
end
+ ::Typhoeus::Hydra.register_stub_finder do |request|
+ VCR::LibraryHooks::Typhoeus::RequestHandler.new(request).handle
+ end
end
end
end
-# TODO: add Typhoeus::Hydra.register_stub_finder API to Typhoeus
-# so we can use that instead of monkey-patching it.
-Typhoeus::Hydra::Stubbing::SharedMethods.class_eval do
- undef find_stub_from_request
- def find_stub_from_request(request)
- VCR::LibraryHooks::Typhoeus::RequestHandler.new(request).handle
- end
-end
-
VCR.configuration.after_library_hooks_loaded do
# ensure WebMock's Typhoeus adapter does not conflict with us here
# (i.e. to double record requests or whatever).
@@ -4,9 +4,9 @@
it_behaves_like 'a hook into an HTTP library', 'typhoeus'
it_performs('version checking', 'Typhoeus',
- :valid => %w[ 0.2.1 0.2.99 ],
- :too_low => %w[ 0.1.0 0.1.31 0.2.0 ],
- :too_high => %w[ 0.3.0 1.0.0 ]
+ :valid => %w[ 0.3.2 0.3.10 ],
+ :too_low => %w[ 0.2.0 0.2.31 0.3.1 ],
+ :too_high => %w[ 0.4.0 1.0.0 ]
) do
before(:each) { @orig_version = Typhoeus::VERSION }
after(:each) { Typhoeus::VERSION = @orig_version }
View
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
'patron' => '~> 0.4.15',
'em-http-request' => '~> 0.3.0',
'curb' => '~> 0.7.15',
- 'typhoeus' => '~> 0.2.1'
+ 'typhoeus' => '~> 0.3.2'
}.each do |lib, version|
s.add_development_dependency lib, version
end unless RUBY_PLATFORM == 'java'

0 comments on commit 46c3be8

Please sign in to comment.