public
Created

Another Typhoeus VCR Interaction Bug

  • Download Gist
Gemfile
Ruby
1 2 3 4 5 6
source :rubygems
 
gem "typhoeus", "~> 0.5.2"
gem "vcr", "~> 2.3.0"
 
gem "rspec"
bug_spec.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
require "bundler/setup"
require "vcr"
require "typhoeus"
 
VCR.configure do |config|
config.cassette_library_dir = File.join( File.dirname(__FILE__),
"vcr_cassettes" )
config.hook_into :typhoeus
end
 
describe "Typhoeus used with VCR" do
it "should work with nested queuing" do
VCR.use_cassette("nested") do
success = false
hydra = Typhoeus::Hydra.new
request = Typhoeus::Request.new("http://xkcd.com/")
request.on_success do |response|
nested = Typhoeus::Request.new("http://yahoo.com/")
nested.on_success do |_|
success = true
end
hydra.queue(nested)
end
 
hydra.queue(request)
hydra.run
 
expect(success).to be_true
end
end
end
 
# $ rspec bug_spec.rb
# F
 
# Failures:
 
# 1) Typhoeus used with VCR should work with nested queuing
# Failure/Error: hydra.run
# NameError:
# instance variable @__typed_vcr_request not defined
# # ./bug_spec.rb:26:in `block (3 levels) in <top (required)>'
# # ./bug_spec.rb:13:in `block (2 levels) in <top (required)>'
 
# Finished in 0.22194 seconds
# 1 example, 1 failure
 
# Failed examples:
 
# rspec ./bug_spec.rb:12 # Typhoeus used with VCR should work with nested queuing

Please change on_success to on_complete since a redirect doesn't count as a successful response: https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/response/status.rb#L49. Or add followlocation: true.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.