Skip to content

Instantly share code, notes, and snippets.

@marios
Created November 4, 2011 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marios/1339082 to your computer and use it in GitHub Desktop.
Save marios/1339082 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'vcr'
require 'test/unit'
require 'rack/test'
require 'excon'
VCR.config do |c|
c.cassette_library_dir = "fixtures"
c.stub_with :excon
c.default_cassette_options = { :record => :new_episodes}
end
class VCRExampleTest < Test::Unit::TestCase
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
Excon.post("http://www.example.com", :body=>params['blob_data'])
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