Skip to content

Instantly share code, notes, and snippets.

@marios
Created June 26, 2012 15:24
Show Gist options
  • Save marios/2996416 to your computer and use it in GitHub Desktop.
Save marios/2996416 to your computer and use it in GitHub Desktop.
gist for "Fix issue with excon mocking and vcr"
require 'rubygems'
require 'vcr'
require 'rack/test'
require 'excon'
VCR.configure do |c|
c.cassette_library_dir = "fixtures"
c.hook_into :excon
c.default_cassette_options = { :record => :all}
end
require 'ruby-debug'
class VCRExampleTest
def self.runtest
#make a new file to post
posted_file = File.new("TestFile", "w+")
posted_file.write("This is a test")
posted_file.flush
params={'blob_data' => Rack::Test::UploadedFile.new(posted_file.path, "text/plain")}
begin
VCR.use_cassette("example1") do
res = Excon.post("http://www.example.com", :body=>params['blob_data'])
puts "OK - #{res.inspect}"
end
rescue => e
puts e.inspect
puts e.backtrace
ensure
File.delete(posted_file.path)
end
end
end
VCRExampleTest.runtest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment