Created
November 4, 2011 10:45
-
-
Save marios/1339082 to your computer and use it in GitHub Desktop.
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 '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