Created
June 26, 2012 15:24
-
-
Save marios/2996416 to your computer and use it in GitHub Desktop.
gist for "Fix issue with excon mocking and vcr"
This file contains hidden or 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 '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