Skip to content

Instantly share code, notes, and snippets.

@l1x
Forked from igrigorik/em-http-vcr.rb
Created February 21, 2012 06:48
Show Gist options
  • Select an option

  • Save l1x/1874453 to your computer and use it in GitHub Desktop.

Select an option

Save l1x/1874453 to your computer and use it in GitHub Desktop.

Revisions

  1. @igrigorik igrigorik created this gist Jan 30, 2011.
    27 changes: 27 additions & 0 deletions em-http-vcr.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    require 'rubygems'
    require 'test/unit'
    require 'em-http'
    require 'vcr'

    VCR.config do |c|
    c.cassette_library_dir = 'fixtures/vcr_cassettes'
    c.http_stubbing_library = :webmock
    end

    class VCRTest < Test::Unit::TestCase
    def make_http_request(url)
    http = nil
    EventMachine.run do
    http = EventMachine::HttpRequest.new(url).get
    http.callback { EventMachine.stop }
    end
    http
    end

    def test_example_dot_com
    VCR.use_cassette('example', :record => :new_episodes) do
    http = make_http_request("http://example.com/")
    assert_match /You have reached this web page by typing.*example\.com/, http.response
    end
    end
    end