Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: myronmarston/vcr
...
head fork: myronmarston/vcr
Checking mergeability… Don't worry, you can still create the pull request.
  • 16 commits
  • 11 files changed
  • 0 commit comments
  • 3 contributors
Commits on May 30, 2011
@myronmarston fix typo d37b7f8
Commits on Jun 03, 2011
@myronmarston Allow relish docs to be re-pushed when I run "rake relish". 4db3d6e
Commits on Jun 14, 2011
@myronmarston Update Faraday to latest. 0308929
@myronmarston Github has changed their url for raw gists. 53023c2
Commits on Jun 20, 2011
@bradleyprice 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
@myronmarston 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
@myronmarston Merge pull request #72 from bradleyisotope/patch-1
option to turn off cassettes is :ignore_cassettes.  error message help sa
cefa21b
@myronmarston Update changelog. b604625
Commits on Jul 05, 2011
@myronmarston Fix excon adapter to handle query specified as a hash.
Closes #73.
a216984
Commits on Jul 15, 2011
@myronmarston Upgrade excon to latest. 113487e
@geemus geemus [excon] stubbed_response should return hash instead of struct 2b7ed5f
@myronmarston Update changelog. 2659fd5
Commits on Jul 16, 2011
@myronmarston Add spec for excon's streaming API. 00f50c2
@myronmarston Fix excon adapter so that it records a response even when excon raise…
…s an error due to an unexpected response.

Closes #77.
ca1e54a
@myronmarston Update excon version requirement to 0.6.5. 042a1b5
Commits on Jul 17, 2011
@myronmarston 1.10.1 release. 7573d96
View
5 .travis.yml
@@ -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
View
13 CHANGELOG.md
@@ -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)
View
8 Rakefile
@@ -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
View
2  features/configuration/filter_sensitive_data.feature
@@ -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`:
View
2  features/http_libraries/net_http.feature
@@ -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)
View
2  lib/vcr.rb
@@ -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
View
59 lib/vcr/http_stubbing_adapters/excon.rb
@@ -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
View
2  lib/vcr/version.rb
@@ -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 }
View
4 spec/support/sinatra_app.rb
@@ -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
View
54 spec/vcr/http_stubbing_adapters/excon_spec.rb
@@ -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
View
4 vcr.gemspec
@@ -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.