Created
November 20, 2012 21:46
-
-
Save JEG2/4121410 to your computer and use it in GitHub Desktop.
Another Typhoeus VCR Interaction Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem "typhoeus", "~> 0.5.2" | |
gem "vcr", "~> 2.3.0" | |
gem "rspec" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please change
on_success
toon_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 addfollowlocation: true
.