vcr 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/CHANGELOG.md +8 -3
- data/README.md +5 -5
- data/Rakefile +3 -1
- data/features/.nav +4 -4
- data/features/{about_the_cucumber_features.md → about_these_examples.md} +0 -2
- data/features/cassettes/format.feature +12 -2
- data/features/cassettes/update_content_length_header.feature +1 -1
- data/features/configuration/allow_http_connections_when_no_cassette.feature +1 -1
- data/features/getting_started.md +0 -2
- data/lib/vcr/http_stubbing_adapters/faraday.rb +11 -1
- data/lib/vcr/middleware/faraday.rb +1 -1
- data/lib/vcr/version.rb +1 -1
- data/spec/support/http_library_adapters.rb +1 -1
- data/spec/support/shared_example_groups/http_library.rb +49 -1
- data/spec/support/shared_example_groups/http_stubbing_adapter.rb +0 -13
- metadata +6 -6
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
1
|
## In git
|
4
2
|
|
5
|
-
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.7.
|
3
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.7.1...master)
|
4
|
+
|
5
|
+
## 1.7.1 (March 19, 2011)
|
6
|
+
|
7
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v1.7.0...v1.7.1)
|
8
|
+
|
9
|
+
* Fix Faraday adapter so that it properly normalizes query parameters
|
10
|
+
in the same way that Faraday itself does.
|
6
11
|
|
7
12
|
## 1.7.0 (March 1, 2011)
|
8
13
|
|
data/README.md
CHANGED
@@ -32,17 +32,17 @@ maintenance) and accurate (the response from example.com will contain the same h
|
|
32
32
|
* Automatically records and replays your HTTP interactions with minimal setup/configuration code.
|
33
33
|
* Supports and works with the HTTP stubbing facilities of multiple libraries. Currently, the
|
34
34
|
following are supported:
|
35
|
-
* FakeWeb
|
36
|
-
* WebMock
|
37
|
-
* Typhoeus
|
38
|
-
* Faraday
|
35
|
+
* [FakeWeb](https://github.com/chrisk/fakeweb)
|
36
|
+
* [WebMock](https://github.com/bblimke/webmock)
|
37
|
+
* [Typhoeus](https://github.com/dbalatero/typhoeus)
|
38
|
+
* [Faraday](https://github.com/technoweenie/faraday)
|
39
39
|
* Supports multiple HTTP libraries:
|
40
40
|
* [Patron](http://github.com/toland/patron) (when using WebMock)
|
41
41
|
* [Curb](http://github.com/taf2/curb) (when using WebMock -- only supports Curb::Easy at the moment)
|
42
42
|
* [HTTPClient](http://github.com/nahi/httpclient) (when using WebMock)
|
43
43
|
* [em-http-request](http://github.com/igrigorik/em-http-request) (when using WebMock)
|
44
44
|
* [Net::HTTP](http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html) (when using FakeWeb and WebMock)
|
45
|
-
* [Typhoeus](https://github.com/
|
45
|
+
* [Typhoeus](https://github.com/dbalatero/typhoeus) (Typhoeus::Hydra, but not Typhoeus::Easy or Typhoeus::Multi)
|
46
46
|
* [Faraday](https://github.com/technoweenie/faraday)
|
47
47
|
* And of course any library built on Net::HTTP, such as [Mechanize](http://github.com/tenderlove/mechanize),
|
48
48
|
[HTTParty](http://github.com/jnunemaker/httparty) or [Rest Client](http://github.com/archiloque/rest-client).
|
data/Rakefile
CHANGED
@@ -47,7 +47,9 @@ namespace :ci do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def ensure_relish_doc_symlinked(filename)
|
50
|
-
|
50
|
+
from_filename = filename.dup
|
51
|
+
from_filename << '.md' unless filename =~ /\.md$/
|
52
|
+
from = File.expand_path("../features/#{from_filename}", __FILE__)
|
51
53
|
to = File.expand_path("../#{filename}", __FILE__)
|
52
54
|
|
53
55
|
if File.symlink?(from)
|
data/features/.nav
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
getting_started.md (Getting Started)
|
2
|
-
CHANGELOG.md (Changelog)
|
3
|
-
|
4
|
-
LICENSE (License)
|
1
|
+
- getting_started.md (Getting Started)
|
2
|
+
- CHANGELOG.md (Changelog)
|
3
|
+
- about_these_examples.md (About These Examples)
|
4
|
+
- LICENSE.md (License)
|
5
5
|
- cassettes:
|
6
6
|
- format.feature
|
7
7
|
- no_cassette.feature
|
@@ -5,8 +5,18 @@ Feature: Cassette format
|
|
5
5
|
human-readable/editable format. A cassette contains an array
|
6
6
|
of HTTP interactions, each of which has the following:
|
7
7
|
|
8
|
-
-
|
9
|
-
|
8
|
+
- request
|
9
|
+
- method
|
10
|
+
- uri
|
11
|
+
- body
|
12
|
+
- headers
|
13
|
+
- response
|
14
|
+
- status
|
15
|
+
- code
|
16
|
+
- message
|
17
|
+
- headers
|
18
|
+
- body
|
19
|
+
- http version
|
10
20
|
|
11
21
|
Scenario Outline: Request/Response data is saved to disk as YAML
|
12
22
|
Given a file named "cassette_format.rb" with:
|
data/features/getting_started.md
CHANGED
@@ -26,7 +26,8 @@ module VCR
|
|
26
26
|
|
27
27
|
def stub_requests(http_interactions, match_attributes)
|
28
28
|
grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
|
29
|
-
|
29
|
+
matcher = request_matcher_with_normalized_uri(request_matcher)
|
30
|
+
queue = stub_queues[matcher]
|
30
31
|
responses.each { |res| queue << res }
|
31
32
|
end
|
32
33
|
end
|
@@ -82,6 +83,15 @@ module VCR
|
|
82
83
|
def hash_of_arrays
|
83
84
|
Hash.new { |h, k| h[k] = [] }
|
84
85
|
end
|
86
|
+
|
87
|
+
def request_matcher_with_normalized_uri(matcher)
|
88
|
+
return matcher unless matcher.uri.is_a?(String) && matcher.uri.include?('+')
|
89
|
+
|
90
|
+
request = matcher.request.dup
|
91
|
+
request.uri = request.uri.gsub('+', '%20')
|
92
|
+
|
93
|
+
RequestMatcher.new(request, matcher.match_attributes)
|
94
|
+
end
|
85
95
|
end
|
86
96
|
end
|
87
97
|
end
|
@@ -18,7 +18,7 @@ module VCR
|
|
18
18
|
elsif response = VCR::HttpStubbingAdapters::Faraday.stubbed_response_for(request_matcher)
|
19
19
|
env.update(
|
20
20
|
:status => response.status.code,
|
21
|
-
:response_headers => correctly_cased_headers(response.headers),
|
21
|
+
:response_headers => correctly_cased_headers(response.headers || {}),
|
22
22
|
:body => response.body
|
23
23
|
)
|
24
24
|
|
data/lib/vcr/version.rb
CHANGED
@@ -11,7 +11,7 @@ HTTP_LIBRARY_ADAPTERS['net/http'] = Module.new do
|
|
11
11
|
|
12
12
|
def make_http_request(method, url, body = nil, headers = {})
|
13
13
|
uri = URI.parse(url)
|
14
|
-
Net::HTTP.new(uri.host, uri.port).send_request(method.to_s.upcase, uri.
|
14
|
+
Net::HTTP.new(uri.host, uri.port).send_request(method.to_s.upcase, uri.request_uri, body, headers)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
NET_CONNECT_NOT_ALLOWED_ERROR = /You can use VCR to automatically record this request and replay it later/
|
2
4
|
|
3
5
|
shared_examples_for "an http library" do |library, supported_request_match_attributes, *other|
|
@@ -12,7 +14,53 @@ shared_examples_for "an http library" do |library, supported_request_match_attri
|
|
12
14
|
# so this gives us another alias we can use for the original method.
|
13
15
|
alias make_request make_http_request
|
14
16
|
|
15
|
-
describe '
|
17
|
+
describe 'making an HTTP request' do
|
18
|
+
let(:status) { VCR::ResponseStatus.new(200, 'OK') }
|
19
|
+
let(:interaction) { VCR::HTTPInteraction.new(request, response) }
|
20
|
+
let(:response_body) { "The response body" }
|
21
|
+
let(:match_requests_on) { [:method, :uri] }
|
22
|
+
let(:record_mode) { :none }
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
subject.stub_requests([interaction], match_requests_on)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the the stubbed request and response has no headers" do
|
29
|
+
let(:request) { VCR::Request.new(:get, 'http://example.com:80/') }
|
30
|
+
let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }
|
31
|
+
|
32
|
+
it 'returns the response for a matching request' do
|
33
|
+
get_body_string(make_http_request(:get, 'http://example.com/')).should == response_body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.test_url(description, url)
|
38
|
+
context "when a URL #{description} has been stubbed" do
|
39
|
+
let(:request) { VCR::Request.new(:get, url) }
|
40
|
+
let(:response) { VCR::Response.new(status, nil, response_body, '1.1') }
|
41
|
+
|
42
|
+
def should_be_pending?
|
43
|
+
return false unless described_class == VCR::HttpStubbingAdapters::WebMock
|
44
|
+
return false unless request.uri.include?(CGI.escape('&'))
|
45
|
+
self.class.included_modules.first.http_library_name == 'EM HTTP Request'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns the expected response for the same request' do
|
49
|
+
pending "WebMock/EM-HTTP bug", :if => should_be_pending? do
|
50
|
+
get_body_string(make_http_request(:get, url)).should == response_body
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
test_url "that has query params", "http://example.com/search?q=param"
|
57
|
+
test_url "with spaces encoded as +", "http://example.com/search?q=a+b"
|
58
|
+
test_url "with spaces encoded as %20", "http://example.com/search?q=a%20b"
|
59
|
+
test_url "with an encoded ampersand", "http://example.com:80/search?q=#{CGI.escape("Q&A")}"
|
60
|
+
test_url "with a complex escaped query param", "http://example.com:80/search?q=#{CGI.escape("A&(! 234k !@ kasdj232\#$ kjw35")}"
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.stub_requests using specific match_attributes' do
|
16
64
|
before(:each) { subject.http_connections_allowed = false }
|
17
65
|
let(:interactions) { VCR::YAML.load_file(File.join(VCR::SPEC_ROOT, 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml')) }
|
18
66
|
|
@@ -43,19 +43,6 @@ shared_examples_for "an http stubbing adapter" do |supported_http_libraries, sup
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe '.stub_requests' do
|
47
|
-
let(:request) { VCR::Request.new(:get, 'http://example.com/') }
|
48
|
-
let(:status) { VCR::ResponseStatus.new(200, 'OK') }
|
49
|
-
let(:response) { VCR::Response.new(status) }
|
50
|
-
let(:interaction) { VCR::HTTPInteraction.new(request, response) }
|
51
|
-
|
52
|
-
it 'works when the request and response has no headers' do
|
53
|
-
expect {
|
54
|
-
subject.stub_requests([interaction], [:method, :uri])
|
55
|
-
}.not_to raise_error
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
46
|
if other.include?(:needs_net_http_extension)
|
60
47
|
describe '.request_uri' do
|
61
48
|
it 'returns the uri for the given http request' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 1.7.
|
9
|
+
- 1
|
10
|
+
version: 1.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Myron Marston
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-19 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -314,7 +314,7 @@ files:
|
|
314
314
|
- benchmarks/http_stubbing_libraries.rb
|
315
315
|
- cucumber.yml
|
316
316
|
- features/.nav
|
317
|
-
- features/
|
317
|
+
- features/about_these_examples.md
|
318
318
|
- features/cassettes/automatic_re_recording.feature
|
319
319
|
- features/cassettes/dynamic_erb.feature
|
320
320
|
- features/cassettes/format.feature
|
@@ -489,7 +489,7 @@ signing_key:
|
|
489
489
|
specification_version: 3
|
490
490
|
summary: Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
|
491
491
|
test_files:
|
492
|
-
- features/
|
492
|
+
- features/about_these_examples.md
|
493
493
|
- features/cassettes/automatic_re_recording.feature
|
494
494
|
- features/cassettes/dynamic_erb.feature
|
495
495
|
- features/cassettes/format.feature
|