vcr 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/features/record_response.feature +6 -1
- data/features/step_definitions/vcr_steps.rb +11 -4
- data/lib/vcr.rb +1 -0
- data/lib/vcr/net_read_adapter_extensions.rb +22 -0
- data/spec/net_read_adapter_extensions_spec.rb +10 -0
- data/vcr.gemspec +104 -0
- metadata +6 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -52,4 +52,9 @@ Feature: Record response
|
|
52
52
|
And we have a "temp/not_the_real_response" file with no previously recorded response for "http://example.com/foo"
|
53
53
|
When I make HTTP get requests to "http://example.com" and "http://example.com/foo" within the "temp/not_the_real_response" unregistered cassette
|
54
54
|
Then the "temp/not_the_real_response" cache file should have a response for "http://example.com" that matches /This is not the real response from example\.com/
|
55
|
-
And the "temp/not_the_real_response" cache file should have a response for "http://example.com/foo" that matches /The requested URL \/foo was not found/
|
55
|
+
And the "temp/not_the_real_response" cache file should have a response for "http://example.com/foo" that matches /The requested URL \/foo was not found/
|
56
|
+
|
57
|
+
Scenario: Record an asynchronous request (such as for mechanize)
|
58
|
+
Given we do not have a "temp/asynchronous" cassette
|
59
|
+
When I make an asynchronous HTTP get request to "http://example.com" within the "temp/asynchronous" unregistered cassette
|
60
|
+
Then the "temp/asynchronous" cache file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
|
@@ -42,23 +42,30 @@ Given /^the previous scenario was tagged with the vcr cassette tag: "([^\"]*)"$/
|
|
42
42
|
VCR::CucumberTags.tags.should include(tag)
|
43
43
|
end
|
44
44
|
|
45
|
-
When /^I make an HTTP get request to "([^\"]*)"$/ do |url|
|
45
|
+
When /^I make an( asynchronous)? HTTP get request to "([^\"]*)"$/ do |asynchronous, url|
|
46
46
|
@http_requests ||= {}
|
47
47
|
begin
|
48
|
-
|
48
|
+
if asynchronous =~ /asynchronous/
|
49
|
+
uri = URI.parse(url)
|
50
|
+
path = uri.path.to_s == '' ? '/' : uri.path
|
51
|
+
result = Net::HTTP.new(uri.host, uri.port).request_get(path) { |r| r.read_body { } }
|
52
|
+
result.body.should be_a(Net::ReadAdapter)
|
53
|
+
else
|
54
|
+
result = Net::HTTP.get_response(URI.parse(url))
|
55
|
+
end
|
49
56
|
rescue => e
|
50
57
|
result = e
|
51
58
|
end
|
52
59
|
@http_requests[url] = result
|
53
60
|
end
|
54
61
|
|
55
|
-
When /^I make
|
62
|
+
When /^I make(?: an)?( asynchronous)? HTTP get requests? to "([^\"]*)"(?: and "([^\"]*)")? within the "([^\"]*)" ?(#{VCR::Cassette::VALID_RECORD_MODES.join('|')})? cassette$/ do |asynchronous, url1, url2, cassette_name, record_mode|
|
56
63
|
record_mode ||= :unregistered
|
57
64
|
record_mode = record_mode.to_sym
|
58
65
|
urls = [url1, url2].select { |u| u.to_s.size > 0 }
|
59
66
|
VCR.with_cassette(cassette_name, :record => record_mode) do
|
60
67
|
urls.each do |url|
|
61
|
-
When %{I make an HTTP get request to "#{url}"}
|
68
|
+
When %{I make an#{asynchronous} HTTP get request to "#{url}"}
|
62
69
|
end
|
63
70
|
end
|
64
71
|
end
|
data/lib/vcr.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module VCR
|
4
|
+
module NetReadAdapter
|
5
|
+
def new(*args, &block)
|
6
|
+
super.extend Extension
|
7
|
+
end
|
8
|
+
|
9
|
+
module Extension
|
10
|
+
def <<(str)
|
11
|
+
(@__body_for_vcr__ ||= '') << str
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_yaml(*args)
|
16
|
+
@__body_for_vcr__.to_yaml(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Net::ReadAdapter.extend VCR::NetReadAdapter
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe 'Net::ReadAdapter extensions' do
|
4
|
+
it 'delegates yaml serialization to the body string' do
|
5
|
+
adapter = Net::ReadAdapter.new(proc { |s| })
|
6
|
+
adapter << 'some text'
|
7
|
+
adapter << ' and some more text'
|
8
|
+
adapter.to_yaml.should == 'some text and some more text'.to_yaml
|
9
|
+
end
|
10
|
+
end
|
data/vcr.gemspec
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{vcr}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Myron Marston"]
|
12
|
+
s.date = %q{2010-02-25}
|
13
|
+
s.description = %q{VCR provides helpers to record HTTP requests for URIs that are not registered with fakeweb, and replay them later. It provides built-in support for cucumber, but works with any ruby testing framework.}
|
14
|
+
s.email = %q{myron.marston@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette1.yml",
|
27
|
+
"features/fixtures/vcr_cassettes/1.8.6/cucumber_tags/replay_cassette2.yml",
|
28
|
+
"features/fixtures/vcr_cassettes/1.8.6/nested_replay_cassette.yml",
|
29
|
+
"features/fixtures/vcr_cassettes/1.8.6/not_the_real_response.yml",
|
30
|
+
"features/fixtures/vcr_cassettes/1.8.6/temp/not_the_real_response.yml",
|
31
|
+
"features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette1.yml",
|
32
|
+
"features/fixtures/vcr_cassettes/1.8.7/cucumber_tags/replay_cassette2.yml",
|
33
|
+
"features/fixtures/vcr_cassettes/1.8.7/nested_replay_cassette.yml",
|
34
|
+
"features/fixtures/vcr_cassettes/1.8.7/not_the_real_response.yml",
|
35
|
+
"features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette1.yml",
|
36
|
+
"features/fixtures/vcr_cassettes/1.9.1/cucumber_tags/replay_cassette2.yml",
|
37
|
+
"features/fixtures/vcr_cassettes/1.9.1/nested_replay_cassette.yml",
|
38
|
+
"features/fixtures/vcr_cassettes/1.9.1/not_the_real_response.yml",
|
39
|
+
"features/record_response.feature",
|
40
|
+
"features/replay_recorded_response.feature",
|
41
|
+
"features/step_definitions/vcr_steps.rb",
|
42
|
+
"features/support/env.rb",
|
43
|
+
"lib/vcr.rb",
|
44
|
+
"lib/vcr/cassette.rb",
|
45
|
+
"lib/vcr/config.rb",
|
46
|
+
"lib/vcr/cucumber_tags.rb",
|
47
|
+
"lib/vcr/fake_web_extensions.rb",
|
48
|
+
"lib/vcr/net_http_extensions.rb",
|
49
|
+
"lib/vcr/net_read_adapter_extensions.rb",
|
50
|
+
"lib/vcr/recorded_response.rb",
|
51
|
+
"spec/cassette_spec.rb",
|
52
|
+
"spec/config_spec.rb",
|
53
|
+
"spec/cucumber_tags_spec.rb",
|
54
|
+
"spec/fake_web_extensions_spec.rb",
|
55
|
+
"spec/fixtures/1.8.6/cassette_spec/example.yml",
|
56
|
+
"spec/fixtures/1.8.7/cassette_spec/example.yml",
|
57
|
+
"spec/fixtures/1.9.1/cassette_spec/example.yml",
|
58
|
+
"spec/net_http_extensions_spec.rb",
|
59
|
+
"spec/net_read_adapter_extensions_spec.rb",
|
60
|
+
"spec/recorded_response_spec.rb",
|
61
|
+
"spec/spec.opts",
|
62
|
+
"spec/spec_helper.rb",
|
63
|
+
"spec/support/temp_cache_dir.rb",
|
64
|
+
"spec/vcr_spec.rb",
|
65
|
+
"vcr.gemspec"
|
66
|
+
]
|
67
|
+
s.homepage = %q{http://github.com/myronmarston/vcr}
|
68
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.rubygems_version = %q{1.3.6}
|
71
|
+
s.summary = %q{Use VCR to record HTTP responses and replay them using fakeweb.}
|
72
|
+
s.test_files = [
|
73
|
+
"spec/cassette_spec.rb",
|
74
|
+
"spec/config_spec.rb",
|
75
|
+
"spec/cucumber_tags_spec.rb",
|
76
|
+
"spec/fake_web_extensions_spec.rb",
|
77
|
+
"spec/net_http_extensions_spec.rb",
|
78
|
+
"spec/net_read_adapter_extensions_spec.rb",
|
79
|
+
"spec/recorded_response_spec.rb",
|
80
|
+
"spec/spec_helper.rb",
|
81
|
+
"spec/support/temp_cache_dir.rb",
|
82
|
+
"spec/vcr_spec.rb"
|
83
|
+
]
|
84
|
+
|
85
|
+
if s.respond_to? :specification_version then
|
86
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
87
|
+
s.specification_version = 3
|
88
|
+
|
89
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
90
|
+
s.add_runtime_dependency(%q<fakeweb>, [">= 1.2.8"])
|
91
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
92
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.6.1"])
|
93
|
+
else
|
94
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
95
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
96
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.1"])
|
97
|
+
end
|
98
|
+
else
|
99
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
100
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
101
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.1"])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Myron Marston
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/vcr/cucumber_tags.rb
|
99
99
|
- lib/vcr/fake_web_extensions.rb
|
100
100
|
- lib/vcr/net_http_extensions.rb
|
101
|
+
- lib/vcr/net_read_adapter_extensions.rb
|
101
102
|
- lib/vcr/recorded_response.rb
|
102
103
|
- spec/cassette_spec.rb
|
103
104
|
- spec/config_spec.rb
|
@@ -107,11 +108,13 @@ files:
|
|
107
108
|
- spec/fixtures/1.8.7/cassette_spec/example.yml
|
108
109
|
- spec/fixtures/1.9.1/cassette_spec/example.yml
|
109
110
|
- spec/net_http_extensions_spec.rb
|
111
|
+
- spec/net_read_adapter_extensions_spec.rb
|
110
112
|
- spec/recorded_response_spec.rb
|
111
113
|
- spec/spec.opts
|
112
114
|
- spec/spec_helper.rb
|
113
115
|
- spec/support/temp_cache_dir.rb
|
114
116
|
- spec/vcr_spec.rb
|
117
|
+
- vcr.gemspec
|
115
118
|
has_rdoc: true
|
116
119
|
homepage: http://github.com/myronmarston/vcr
|
117
120
|
licenses: []
|
@@ -148,6 +151,7 @@ test_files:
|
|
148
151
|
- spec/cucumber_tags_spec.rb
|
149
152
|
- spec/fake_web_extensions_spec.rb
|
150
153
|
- spec/net_http_extensions_spec.rb
|
154
|
+
- spec/net_read_adapter_extensions_spec.rb
|
151
155
|
- spec/recorded_response_spec.rb
|
152
156
|
- spec/spec_helper.rb
|
153
157
|
- spec/support/temp_cache_dir.rb
|