Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: myronmarston/vcr
...
head fork: myronmarston/vcr
  • 16 commits
  • 11 files changed
  • 0 commit comments
  • 3 contributors
Commits on May 30, 2011
Myron Marston fix typo d37b7f8
Commits on Jun 03, 2011
Myron Marston Allow relish docs to be re-pushed when I run "rake relish". 4db3d6e
Commits on Jun 14, 2011
Myron Marston Update Faraday to latest. 0308929
Myron Marston Github has changed their url for raw gists. 53023c2
Commits on Jun 20, 2011
Bradley Price bradleyprice option to turn off cassettes is :ignore_cassettes. error message help…
… said it was :ignore_cassette, singular. This makes it nicer when you run into this problem :)
d70f8e2
Myron Marston Just run against 1.8.7 and 1.9.2 for now as I seem to regularly get b…
…acked up on travis.
1cca872
Commits on Jun 21, 2011
Myron Marston Merge pull request #72 from bradleyisotope/patch-1
option to turn off cassettes is :ignore_cassettes.  error message help sa
cefa21b
Myron Marston Update changelog. b604625
Commits on Jul 05, 2011
Myron Marston Fix excon adapter to handle query specified as a hash.
Closes #73.
a216984
Commits on Jul 15, 2011
Myron Marston Upgrade excon to latest. 113487e
Wesley Beary geemus [excon] stubbed_response should return hash instead of struct 2b7ed5f
Myron Marston Update changelog. 2659fd5
Commits on Jul 16, 2011
Myron Marston Add spec for excon's streaming API. 00f50c2
Myron Marston Fix excon adapter so that it records a response even when excon raise…
…s an error due to an unexpected response.

Closes #77.
ca1e54a
Myron Marston Update excon version requirement to 0.6.5. 042a1b5
Commits on Jul 17, 2011
Myron Marston 1.10.1 release. 7573d96
5 .travis.yml
View
@@ -1,11 +1,6 @@
script: "bundle exec rake ci:build"
rvm:
- - 1.8.6
- 1.8.7
- - 1.9.1
- 1.9.2
- - ree
- - jruby
- - rbx
env:
- CI=true
13 CHANGELOG.md
View
@@ -1,6 +1,17 @@
## In git
-[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.10.0...master)
+[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.10.1...master)
+
+## 1.10.1 (July 16, 2011)
+
+[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.10.0...v1.10.1)
+
+* Fix typo in error message [Bradley](https://github.com/bradleyisotope).
+* Fix excon adapter to properly handle queries specified as a hash.
+* Fix excon adapter to stub a response with a hash as excon expects
+ [Wesley Beary](https://github.com/geemus).
+* Fix excon adapter so that it records a response even when excon raises
+ an error due to an unexpected response.
## 1.10.0 (May 18, 2011)
8 Rakefile
View
@@ -70,11 +70,15 @@ task :relish do
end
require 'vcr/version'
- sh "relish versions:add myronmarston/vcr:#{VCR.version}"
+ sh "relish versions:add myronmarston/vcr:#{VCR.version}" if ENV['NEW_RELISH_RELEASE']
sh "relish push vcr:#{VCR.version}"
end
-task :release => :relish
+task :prep_relish_release do
+ ENV['NEW_RELISH_RELEASE'] = 'true'
+end
+
+task :release => [:prep_relish_release, :relish]
# For gem-test: http://gem-testers.org/
task :test => :spec
2  features/configuration/filter_sensitive_data.feature
View
@@ -2,7 +2,7 @@ Feature: Filter sensitive data
The `filter_sensitive_data` configuration option can be used to prevent
sensitive data from being written to your cassette files. This may be
- important if you commit your cassettes files to source controla and do
+ important if you commit your cassettes files to source control and do
not want your sensitive data exposed. Pass the following arguments to
`filter_sensitive_data`:
2  features/http_libraries/net_http.feature
View
@@ -146,7 +146,7 @@ Feature: Net::HTTP
c.cassette_library_dir = 'cassettes'
end
- uri = URI("https://gist.github.com/raw/fb555cb593f3349d53af/6921dd638337d3f6a51b0e02e7f30e3c414f70d6/vcr_gist")
+ uri = URI("https://raw.github.com/gist/fb555cb593f3349d53af/6921dd638337d3f6a51b0e02e7f30e3c414f70d6/vcr_gist")
VCR.use_cassette('https', :record => :new_episodes) do
http = Net::HTTP.new(uri.host, uri.port)
2  lib/vcr.rb
View
@@ -58,7 +58,7 @@ def insert_cassette(name, options = {})
cassette
elsif !ignore_cassettes?
message = "VCR is turned off. You must turn it on before you can insert a cassette. " +
- "Or you can use the `:ignore_cassette => true` option to completely ignore cassette insertions."
+ "Or you can use the `:ignore_cassettes => true` option to completely ignore cassette insertions."
raise TurnedOffError.new(message)
end
end
59 lib/vcr/http_stubbing_adapters/excon.rb
View
@@ -8,7 +8,7 @@ module Excon
class HttpConnectionNotAllowedError < StandardError; end
- MINIMUM_VERSION = '0.6.2'
+ MINIMUM_VERSION = '0.6.5'
MAXIMUM_VERSION = '0.6'
attr_writer :http_connections_allowed
@@ -119,24 +119,40 @@ def request_should_be_ignored?
end
def stubbed_response
- unless defined?(@stubbed_response)
- @stubbed_response = VCR::HttpStubbingAdapters::Excon.stubbed_response_for(vcr_request)
-
- if @stubbed_response && @stubbed_response.headers
- @stubbed_response.headers = normalized_headers(@stubbed_response.headers)
+ @stubbed_response ||= begin
+ if stubbed_response = VCR::HttpStubbingAdapters::Excon.stubbed_response_for(vcr_request)
+ {
+ :body => stubbed_response.body,
+ :headers => normalized_headers(stubbed_response.headers || {}),
+ :status => stubbed_response.status.code
+ }
end
end
-
- @stubbed_response
end
def http_connections_allowed?
VCR::HttpStubbingAdapters::Excon.http_connections_allowed?
end
+ def response_from_excon_error(error)
+ if error.respond_to?(:response)
+ error.response
+ elsif error.respond_to?(:socket_error)
+ response_from_excon_error(error.socket_error)
+ else
+ warn "WARNING: VCR could not extract a response from Excon error (#{error.inspect})"
+ end
+ end
+
def perform_real_request
connection = ::Excon.new(uri)
- response = connection.request(params.merge(:mock => false))
+
+ response = begin
+ connection.request(params.merge(:mock => false))
+ rescue ::Excon::Errors::Error => e
+ yield response_from_excon_error(e) if block_given?
+ raise e
+ end
yield response if block_given?
@@ -153,10 +169,27 @@ def record_interaction
end
def uri
- @uri ||= begin
- uri = "#{params[:scheme]}://#{params[:host]}:#{params[:port]}#{params[:path]}"
- uri << "?#{params[:query]}" if params[:query]
- uri
+ @uri ||= "#{params[:scheme]}://#{params[:host]}:#{params[:port]}#{params[:path]}#{query}"
+ end
+
+ def query
+ @query ||= case params[:query]
+ when String
+ "?#{params[:query]}"
+ when Hash
+ qry = '?'
+ for key, values in params[:query]
+ if values.nil?
+ qry << key.to_s << '&'
+ else
+ for value in [*values]
+ qry << key.to_s << '=' << CGI.escape(value.to_s) << '&'
+ end
+ end
+ end
+ qry.chop! # remove trailing '&'
+ else
+ ''
end
end
2  lib/vcr/version.rb
View
@@ -3,7 +3,7 @@ module VCR
def version
@version ||= begin
- string = '1.10.0'
+ string = '1.10.1'
def string.parts
split('.').map { |p| p.to_i }
4 spec/support/sinatra_app.rb
View
@@ -6,6 +6,10 @@ class SinatraApp < ::Sinatra::Base
"GET to root"
end
+ get '/search' do
+ "query: #{params[:q]}"
+ end
+
get '/localhost_test' do
"Localhost response"
end
54 spec/vcr/http_stubbing_adapters/excon_spec.rb
View
@@ -7,8 +7,8 @@
:status_message_not_exposed
it_performs('version checking',
- :valid => %w[ 0.6.2 0.6.99 ],
- :too_low => %w[ 0.5.99 0.6.1 ],
+ :valid => %w[ 0.6.5 0.6.99 ],
+ :too_low => %w[ 0.5.99 0.6.4 ],
:too_high => %w[ 0.7.0 1.0.0 ]
) do
before(:each) { @orig_version = Excon::VERSION }
@@ -19,5 +19,55 @@
Excon::VERSION = version
end
end
+
+ context "when the query is specified as a hash option" do
+ let(:excon) { ::Excon.new("http://localhost:#{VCR::SinatraApp.port}/search") }
+
+ it 'properly records and plays back the response' do
+ described_class.http_connections_allowed = true
+ recorded, played_back = [1, 2].map do
+ VCR.use_cassette('excon_query', :record => :once) do
+ excon.request(:method => :get, :query => { :q => 'Tolkien' }).body
+ end
+ end
+
+ recorded.should == played_back
+ recorded.should == 'query: Tolkien'
+ end
+ end
+
+ context "when Excon's streaming API is used" do
+ it 'properly records and plays back the response' do
+ described_class.http_connections_allowed = true
+ recorded, played_back = [1, 2].map do
+ chunks = []
+
+ VCR.use_cassette('excon_streaming', :record => :once) do
+ Excon.get("http://localhost:#{VCR::SinatraApp.port}/foo") do |chunk, remaining_bytes, total_bytes|
+ chunks << chunk
+ end
+ end
+
+ chunks.join
+ end
+
+ recorded.should == played_back
+ recorded.should == "FOO!"
+ end
+ end
+
+ context 'when Excon raises an error due to an unexpected response status' do
+ it 'still records properly' do
+ described_class.http_connections_allowed = true
+
+ VCR.should_receive(:record_http_interaction) do |interaction|
+ interaction.response.status.code.should == 404
+ end
+
+ expect {
+ Excon.get("http://localhost:#{VCR::SinatraApp.port}/not_found", :expects => 200)
+ }.to raise_error(Excon::Errors::Error)
+ end
+ end
end
4 vcr.gemspec
View
@@ -30,9 +30,9 @@ Gem::Specification.new do |s|
'webmock' => '~> 1.6.4',
'addressable' => '~> 2.2.6',
- 'faraday' => '~> 0.6.0',
+ 'faraday' => '~> 0.7.2',
'httpclient' => '~> 2.1.5.2',
- 'excon' => '~> 0.6.2',
+ 'excon' => '~> 0.6.5',
'timecop' => '~> 0.3.5',
'rack' => '1.1.0',

No commit comments for this range

Something went wrong with that request. Please try again.