vcr 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.3.1 April 10, 2010
2
+ * Fixed a bug: when Net::HTTP#request was called with a block that had a return statement, the response was not being recorded.
3
+
1
4
  == 0.3.0 March 24, 2010
2
5
  * Renamed a bunch of methods, replacing them with method names that more clearly fit the VCR/cassette metaphor:
3
6
  * VCR.create_cassette! => VCR.insert_cassette
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -70,3 +70,8 @@ Feature: Record response
70
70
  When I make an HTTP get request to "http://example.com" within the "temp/record_none_cassette" none cassette, allowing requests matching /example.com/
71
71
  Then the response for "http://example.com" should match /You have reached this web page by typing.*example\.com/
72
72
  And there should not be a "temp/record_none_cassette" library file
73
+
74
+ Scenario: Record a request with a block with a return statement
75
+ Given we do not have a "temp/block_with_a_return" cassette
76
+ When I make a returning block HTTP get request to "http://example.com" within the "temp/block_with_a_return" new_episodes cassette
77
+ Then the "temp/block_with_a_return" library file should have a response for "http://example.com" that matches /You have reached this web page by typing.*example\.com/
@@ -26,6 +26,12 @@ module VCRHelpers
26
26
  end
27
27
  @http_requests[url] += [result]
28
28
  end
29
+
30
+ def perform_get_with_returning_block(uri, path)
31
+ Net::HTTP.new(uri.host, uri.port).request(Net::HTTP::Get.new(path, {})) do |response|
32
+ return response
33
+ end
34
+ end
29
35
  end
30
36
  World(VCRHelpers)
31
37
 
@@ -88,6 +94,12 @@ When /^I make a recursive HTTP post request to "([^\"]*)"$/ do |url|
88
94
  end
89
95
  end
90
96
 
97
+ When /^I make a returning block HTTP get request to "([^\"]*)"$/ do |url|
98
+ capture_response(url) do |uri, path|
99
+ perform_get_with_returning_block(uri, path)
100
+ end
101
+ end
102
+
91
103
  When /^I make (.*HTTP (?:get|post)) requests? to "([^\"]*)"(?: and "([^\"]*)")? within the "([^\"]*)" ?(#{VCR::Cassette::VALID_RECORD_MODES.join('|')})? cassette(?:, allowing requests matching \/([^\/]+)\/)?$/ do |http_request_type, url1, url2, cassette_name, record_mode, allowed|
92
104
  options = { :record => (record_mode ? record_mode.to_sym : :new_episodes) }
93
105
  options[:allow_real_http] = lambda { |uri| uri.to_s =~ /#{allowed}/ } if allowed.to_s.size > 0
@@ -8,8 +8,9 @@ module Net
8
8
  if (cassette = VCR.current_cassette) && cassette.allow_real_http_requests_to?(uri)
9
9
  FakeWeb.with_allow_net_connect_set_to(true) { request_without_vcr(request, body, &block) }
10
10
  else
11
- response = request_without_vcr(request, body, &block)
11
+ response = request_without_vcr(request, body)
12
12
  __store_response_with_vcr__(response, request) if @__request_with_vcr_call_count == 1
13
+ yield response if block_given?
13
14
  response
14
15
  end
15
16
  ensure
@@ -17,6 +17,12 @@ describe "Net::HTTP Extensions" do
17
17
  end
18
18
 
19
19
  describe 'a request that is not registered with FakeWeb' do
20
+ def perform_get_with_returning_block
21
+ Net::HTTP.new('example.com', 80).request(Net::HTTP::Get.new('/', {})) do |response|
22
+ return response
23
+ end
24
+ end
25
+
20
26
  it 'calls #store_recorded_response! on the current cassette' do
21
27
  recorded_response = VCR::RecordedResponse.new(:get, 'http://example.com:80/', :example_response)
22
28
  VCR::RecordedResponse.should_receive(:new).with(:get, 'http://example.com:80/', an_instance_of(Net::HTTPOK)).and_return(recorded_response)
@@ -28,6 +34,11 @@ describe "Net::HTTP Extensions" do
28
34
  @current_cassette.should_receive(:store_recorded_response!).once
29
35
  Net::HTTP.new('example.com', 80).post('/', nil)
30
36
  end
37
+
38
+ it 'calls #store_recorded_response! when Net::HTTP#request is called with a block with a return statement' do
39
+ @current_cassette.should_receive(:store_recorded_response!).once
40
+ perform_get_with_returning_block
41
+ end
31
42
  end
32
43
 
33
44
  describe 'a request that is registered with FakeWeb' do
data/vcr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vcr}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Myron Marston"]
12
- s.date = %q{2010-03-24}
12
+ s.date = %q{2010-04-10}
13
13
  s.description = %q{VCR provides helpers to record HTTP requests for URIs that are not registered with fakeweb, and replay them later. It works with any ruby testing framework, and provides built-in support for cucumber.}
14
14
  s.email = %q{myron.marston@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Myron Marston
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-24 00:00:00 -07:00
17
+ date: 2010-04-10 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency