Skip to content

Instantly share code, notes, and snippets.

@alkema
Created March 20, 2012 01:53
Show Gist options
  • Save alkema/2129918 to your computer and use it in GitHub Desktop.
Save alkema/2129918 to your computer and use it in GitHub Desktop.
vcr-page-rankr.rb
I expect there to be two cassettes, and there is just one...
source 'https://rubygems.org'
gem 'vcr'
gem 'fakeweb'
gem 'PageRankr'
➜ vcr-test-thing sudo ngrep -q '^GET .* HTTP/1.[01]'
T 10.0.2.40:55124 -> 23.21.145.76:80 [AP]
GET /data?cli=10&dat=snbamz&url=boingboing.net HTTP/1.1..Host: data.alexa.com..Accept: */*..Accept-Encoding: deflate, gzip..User-Agent: Page Rankr....
^C%
➜ vcr-page-rankr bundle exec ruby vcr-page-rankr.rb
Loaded suite vcr-page-rankr
Started
..
Finished in 0.346584 seconds.
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 12708
➜ vcr-page-rankr ls fixtures/vcr_cassettes
synopsis.yml
require 'rubygems'
require 'test/unit'
require 'vcr'
require 'page_rankr'
require 'pp'
VCR.configure do |c|
c.cassette_library_dir = 'fixtures/vcr_cassettes'
c.hook_into :fakeweb
end
class VCRTest < Test::Unit::TestCase
def test_page_rank_boing_boing
VCR.use_cassette('boing-boing') do
response = PageRankr.ranks('http://boingboing.net', :alexa_global)
assert_equal 2316, response[:alexa_global]
end
end
def test_example_dot_com
VCR.use_cassette('synopsis') do
response = Net::HTTP.get_response(URI('http://www.iana.org/domains/example/'))
assert_match /Example Domains/, response.body
end
end
end
@alkema
Copy link
Author

alkema commented Mar 20, 2012

That works great. Thanks Myron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment