ephemeral_response 0.3.1 → 0.3.2

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/.gitignore CHANGED
@@ -14,8 +14,11 @@ tmtags
14
14
  *.swp
15
15
 
16
16
  ## PROJECT::GENERAL
17
+ .rvmrc
17
18
  coverage
18
19
  rdoc
19
20
  pkg
20
21
 
21
22
  ## PROJECT::SPECIFIC
23
+ /.bundle
24
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/History.markdown CHANGED
@@ -1,6 +1,15 @@
1
1
  History
2
2
  =======
3
3
 
4
+ 0.3.2 / 2010-07-30
5
+ ------------------
6
+
7
+ #### Bug Fix
8
+
9
+ * Net::HTTP.request now yields the response when a fixture exists
10
+ * Net::HTTPResponse#read\_body works when a fixture exists
11
+ * OpenURI compatibility (it depends on #read_body)
12
+
4
13
  0.3.1 / 2010-06-29
5
14
  --------------
6
15
 
data/README.markdown CHANGED
@@ -110,6 +110,10 @@ method `one_day`
110
110
  one_day * 30 # Expire in thirty days: 60 * 60 * 24 * 30
111
111
  end
112
112
 
113
+ Never let fixtures expire by setting skip\_expiration to true.
114
+
115
+ EphemeralResponse::Configuration.skip_expiration = true
116
+
113
117
  ### Selenium Tip
114
118
 
115
119
  Always allow requests to be made to a host by adding it to the white list.
@@ -118,17 +122,13 @@ the local server.
118
122
 
119
123
  EphemeralResponse::Configuration.white_list = "localhost", "127.0.0.1"
120
124
 
121
- Never let fixtures expire by setting skip\_expiration to true.
122
-
123
- EphemeralResponse::Configuration.skip_expiration = true
124
-
125
- All together now!
125
+ ### All together now!
126
126
 
127
127
  EphemeralResponse.configure do |config|
128
128
  config.fixture_directory = "test/fixtures/ephemeral_response"
129
129
  config.expiration = lambda { one_day * 30 }
130
- config.white_list = 'localhost'
131
130
  config.skip_expiration = true
131
+ config.white_list = 'localhost'
132
132
  end
133
133
 
134
134
  ## Similar Projects
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ begin
13
13
  gem.email = "sandro.turriate@gmail.com"
14
14
  gem.homepage = "http://github.com/sandro/ephemeral_response"
15
15
  gem.authors = ["Sandro Turriate", "Les Hill"]
16
+ gem.add_development_dependency "jeweler", ">= 1.4.0"
16
17
  gem.add_development_dependency "rspec", ">= 1.2.9"
17
18
  gem.add_development_dependency "yard", ">= 0.5.0"
18
19
  gem.add_development_dependency "fakefs", ">= 0.2.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -0,0 +1,107 @@
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{ephemeral_response}
8
+ s.version = "0.3.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Sandro Turriate", "Les Hill"]
12
+ s.date = %q{2010-07-30}
13
+ s.description = %q{
14
+ Save HTTP responses to give your tests a hint of reality.
15
+ Responses are saved into your fixtures directory and are used for subsequent web requests until they expire.
16
+ }
17
+ s.email = %q{sandro.turriate@gmail.com}
18
+ s.extra_rdoc_files = [
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "Gemfile",
25
+ "History.markdown",
26
+ "MIT_LICENSE",
27
+ "README.markdown",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "ephemeral_response.gemspec",
31
+ "examples/custom_cache_key.rb",
32
+ "examples/open_uri_compatibility.rb",
33
+ "examples/simple_benchmark.rb",
34
+ "examples/white_list.rb",
35
+ "lib/ephemeral_response.rb",
36
+ "lib/ephemeral_response/configuration.rb",
37
+ "lib/ephemeral_response/fixture.rb",
38
+ "lib/ephemeral_response/net_http.rb",
39
+ "lib/ephemeral_response/request.rb",
40
+ "spec/ephemeral_response/configuration_spec.rb",
41
+ "spec/ephemeral_response/fixture_spec.rb",
42
+ "spec/ephemeral_response/net_http_spec.rb",
43
+ "spec/ephemeral_response_spec.rb",
44
+ "spec/integration/custom_identifier_spec.rb",
45
+ "spec/integration/normal_flow_spec.rb",
46
+ "spec/integration/read_body_compatibility_spec.rb",
47
+ "spec/integration/unique_fixtures_spec.rb",
48
+ "spec/integration/white_list_spec.rb",
49
+ "spec/spec.opts",
50
+ "spec/spec_helper.rb",
51
+ "spec/support/clear_fixtures.rb",
52
+ "spec/support/fakefs_ext.rb",
53
+ "spec/support/rack_reflector.rb",
54
+ "spec/support/time.rb"
55
+ ]
56
+ s.homepage = %q{http://github.com/sandro/ephemeral_response}
57
+ s.rdoc_options = ["--charset=UTF-8"]
58
+ s.require_paths = ["lib"]
59
+ s.rubygems_version = %q{1.3.7}
60
+ s.summary = %q{Save HTTP responses to give your tests a hint of reality.}
61
+ s.test_files = [
62
+ "spec/ephemeral_response/configuration_spec.rb",
63
+ "spec/ephemeral_response/fixture_spec.rb",
64
+ "spec/ephemeral_response/net_http_spec.rb",
65
+ "spec/ephemeral_response_spec.rb",
66
+ "spec/integration/custom_identifier_spec.rb",
67
+ "spec/integration/normal_flow_spec.rb",
68
+ "spec/integration/read_body_compatibility_spec.rb",
69
+ "spec/integration/unique_fixtures_spec.rb",
70
+ "spec/integration/white_list_spec.rb",
71
+ "spec/spec_helper.rb",
72
+ "spec/support/clear_fixtures.rb",
73
+ "spec/support/fakefs_ext.rb",
74
+ "spec/support/rack_reflector.rb",
75
+ "spec/support/time.rb",
76
+ "examples/custom_cache_key.rb",
77
+ "examples/open_uri_compatibility.rb",
78
+ "examples/simple_benchmark.rb",
79
+ "examples/white_list.rb"
80
+ ]
81
+
82
+ if s.respond_to? :specification_version then
83
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
84
+ s.specification_version = 3
85
+
86
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
87
+ s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
88
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
89
+ s.add_development_dependency(%q<yard>, [">= 0.5.0"])
90
+ s.add_development_dependency(%q<fakefs>, [">= 0.2.1"])
91
+ s.add_development_dependency(%q<unicorn>, [">= 1.0.0"])
92
+ else
93
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
94
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
95
+ s.add_dependency(%q<yard>, [">= 0.5.0"])
96
+ s.add_dependency(%q<fakefs>, [">= 0.2.1"])
97
+ s.add_dependency(%q<unicorn>, [">= 1.0.0"])
98
+ end
99
+ else
100
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
101
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
102
+ s.add_dependency(%q<yard>, [">= 0.5.0"])
103
+ s.add_dependency(%q<fakefs>, [">= 0.2.1"])
104
+ s.add_dependency(%q<unicorn>, [">= 1.0.0"])
105
+ end
106
+ end
107
+
@@ -3,15 +3,15 @@ require 'rubygems'
3
3
  require 'lib/ephemeral_response'
4
4
  require 'benchmark'
5
5
 
6
- EphemeralResponse::Configuration.expiration = 15
7
- EphemeralResponse.activate
8
-
9
6
  EphemeralResponse.configure do |config|
7
+ config.expiration = 1
10
8
  config.register('example.com') do |request|
11
9
  "#{request.uri.host}#{request.method}#{request.path}"
12
10
  end
13
11
  end
14
12
 
13
+ EphemeralResponse.activate
14
+
15
15
  def benchmark_request(number=1)
16
16
  uri = URI.parse('http://example.com/')
17
17
  time = Benchmark.realtime do
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift("lib")
2
+ require 'lib/ephemeral_response'
3
+ require 'benchmark'
4
+ require 'open-uri'
5
+
6
+ EphemeralResponse::Configuration.expiration = 5
7
+ EphemeralResponse.activate
8
+
9
+ # Run benchmarks against thefuckingweather.com
10
+ # The first request takes much longer than the rest
11
+ def benchmark_request(number=1)
12
+ uri = URI.parse('http://thefuckingweather.com/?RANDLOC=')
13
+ time = Benchmark.realtime do
14
+ uri.open
15
+ end
16
+ puts "Request #{number} took #{time} secs"
17
+ end
18
+
19
+ 5.times {|n| benchmark_request n + 1 }
@@ -20,7 +20,7 @@ module EphemeralResponse
20
20
  end
21
21
 
22
22
  def host_registry
23
- @host_registry ||= Hash.new(lambda {})
23
+ @host_registry ||= Hash.new(proc {})
24
24
  end
25
25
 
26
26
  def register(host, &block)
@@ -39,11 +39,16 @@ module EphemeralResponse
39
39
  end
40
40
  end
41
41
 
42
- def self.respond_to(uri, request)
43
- find_or_initialize(uri, request) do |fixture|
42
+ def self.respond_to(uri, request, request_block)
43
+ fixture = find_or_initialize(uri, request)
44
+ if fixture.new?
44
45
  fixture.response = yield
46
+ fixture.response.instance_variable_set(:@body, fixture.response.body.to_s)
45
47
  fixture.register
46
- end.response
48
+ elsif request_block
49
+ request_block.call fixture.response
50
+ end
51
+ fixture.response
47
52
  end
48
53
 
49
54
  def initialize(uri, request)
@@ -69,6 +74,10 @@ module EphemeralResponse
69
74
  request.method
70
75
  end
71
76
 
77
+ def new?
78
+ !self.class.fixtures.has_key?(identifier)
79
+ end
80
+
72
81
  def normalized_name
73
82
  [uri.host, method, fs_path].compact.join("_").gsub(/[\/]/, '-')
74
83
  end
@@ -9,12 +9,12 @@ module Net
9
9
  end
10
10
  private :connect
11
11
 
12
- def do_start_without_ephemeral_response
12
+ def do_start_with_ephemeral_response
13
13
  D "EphemeralResponse: establishing connection to #{uri}"
14
14
  connect_without_ephemeral_response
15
15
  @started = true
16
16
  end
17
- private :do_start_without_ephemeral_response
17
+ private :do_start_with_ephemeral_response
18
18
 
19
19
  def generate_uri(request)
20
20
  scheme = use_ssl? ? "https" : "http"
@@ -23,10 +23,48 @@ module Net
23
23
 
24
24
  def request(request, body = nil, &block)
25
25
  generate_uri(request)
26
- EphemeralResponse::Fixture.respond_to(uri, request) do
27
- do_start_without_ephemeral_response
26
+ EphemeralResponse::Fixture.respond_to(uri, request, block) do
27
+ do_start_with_ephemeral_response
28
28
  request_without_ephemeral_response(request, body, &block)
29
29
  end
30
30
  end
31
31
  end
32
+
33
+ module PersistentReadAdapter
34
+ def _buffer
35
+ @_buffer ||= ""
36
+ end
37
+
38
+ def <<(str)
39
+ _buffer << str
40
+ super
41
+ end
42
+
43
+ def to_yaml(opts = {})
44
+ _buffer.to_yaml opts
45
+ end
46
+
47
+ def to_s
48
+ _buffer
49
+ end
50
+ end
51
+
52
+ class HTTPResponse
53
+ alias procdest_without_ephemeral_response procdest
54
+ alias read_body_without_ephemeral_response read_body
55
+
56
+ def procdest(dest, block)
57
+ to = procdest_without_ephemeral_response(dest, block)
58
+ to.extend PersistentReadAdapter
59
+ end
60
+
61
+ def read_body(dest = nil, &block)
62
+ if @read
63
+ yield @body if block_given?
64
+ @body
65
+ else
66
+ read_body_without_ephemeral_response(dest, &block)
67
+ end
68
+ end
69
+ end
32
70
  end
@@ -9,7 +9,7 @@ require 'ephemeral_response/request'
9
9
  require 'ephemeral_response/fixture'
10
10
 
11
11
  module EphemeralResponse
12
- VERSION = "0.3.1".freeze
12
+ VERSION = "0.3.2".freeze
13
13
 
14
14
  def self.activate
15
15
  deactivate
@@ -24,6 +24,10 @@ module EphemeralResponse
24
24
  alias_method(:connect, :connect_without_ephemeral_response) if private_method_defined?(:connect_without_ephemeral_response)
25
25
  alias_method(:request, :request_without_ephemeral_response) if method_defined?(:request_without_ephemeral_response)
26
26
  end
27
+ Net::HTTPResponse.class_eval do
28
+ alias_method(:procdest, :procdest_without_ephemeral_response) if private_method_defined?(:procdest_without_ephemeral_response)
29
+ alias_method(:read_body, :read_body_without_ephemeral_response) if method_defined?(:read_body_without_ephemeral_response)
30
+ end
27
31
  end
28
32
 
29
33
  def self.fixtures
@@ -26,13 +26,13 @@ describe EphemeralResponse::Configuration do
26
26
 
27
27
  context "setting a block" do
28
28
  it "returns the value of the block" do
29
- subject.expiration = lambda { one_day * 7 }
29
+ subject.expiration = proc { one_day * 7 }
30
30
  subject.expiration.should == 604800
31
31
  end
32
32
 
33
33
  it "raises an error when the return value of the block is not a FixNum" do
34
34
  expect do
35
- subject.expiration = lambda { "1 day" }
35
+ subject.expiration = proc { "1 day" }
36
36
  end.to raise_exception(TypeError, "expiration must be expressed in seconds")
37
37
  end
38
38
  end
@@ -6,7 +6,11 @@ describe EphemeralResponse::Fixture do
6
6
  let(:fixture_directory) { File.expand_path EphemeralResponse::Configuration.fixture_directory }
7
7
  let(:request) { Net::HTTP::Get.new '/' }
8
8
  let(:uri) { URI.parse("http://example.com/") }
9
- let(:fixture) { EphemeralResponse::Fixture.new(uri, request) { |f| f.response = "hello world"} }
9
+ let(:fixture) do
10
+ EphemeralResponse::Fixture.new(uri, request) do |f|
11
+ f.response = OpenStruct.new(:body => "hello world")
12
+ end
13
+ end
10
14
 
11
15
  describe ".load_all" do
12
16
  it "returns the empty fixtures hash when the fixture directory doesn't exist" do
@@ -115,7 +119,9 @@ describe EphemeralResponse::Fixture do
115
119
 
116
120
  it "returns flow back to net/http" do
117
121
  2.times do
118
- EphemeralResponse::Fixture.respond_to(fixture.uri, request) {}
122
+ EphemeralResponse::Fixture.respond_to(fixture.uri, request, nil) do
123
+ stub(:body => "")
124
+ end
119
125
  EphemeralResponse::Fixture.fixtures[fixture.identifier].should be_nil
120
126
  end
121
127
  end
@@ -129,7 +135,9 @@ describe EphemeralResponse::Fixture do
129
135
  end
130
136
 
131
137
  it "returns flow to net/http when host is not normalized" do
132
- EphemeralResponse::Fixture.respond_to(uri, request) {}
138
+ EphemeralResponse::Fixture.respond_to(uri, request, nil) do
139
+ stub(:body => "")
140
+ end
133
141
  EphemeralResponse::Fixture.fixtures[fixture.identifier].should be_nil
134
142
  end
135
143
  end
@@ -139,22 +147,38 @@ describe EphemeralResponse::Fixture do
139
147
  context "fixture loaded" do
140
148
  it "returns the fixture response" do
141
149
  fixture.register
142
- response = EphemeralResponse::Fixture.respond_to(fixture.uri, request)
143
- response.should == "hello world"
150
+ response = EphemeralResponse::Fixture.respond_to(fixture.uri, request, nil)
151
+ response.body.should == "hello world"
152
+ end
153
+
154
+ it "yields the response body to the request block" do
155
+ fixture.register
156
+ reverse_body = nil
157
+ request_block = lambda {|response| reverse_body = response.body.reverse}
158
+ response = EphemeralResponse::Fixture.respond_to(fixture.uri, request, request_block)
159
+ reverse_body.should == response.body.reverse
144
160
  end
145
161
  end
146
162
 
147
163
  context "fixture not loaded" do
148
164
  it "sets the response to the block" do
149
- EphemeralResponse::Fixture.respond_to(fixture.uri, request) do
150
- "new response"
165
+ EphemeralResponse::Fixture.respond_to(fixture.uri, request, nil) do
166
+ stub(:body => "new response")
151
167
  end
152
- EphemeralResponse::Fixture.fixtures[fixture.identifier].response.should == "new response"
168
+ EphemeralResponse::Fixture.fixtures[fixture.identifier].response.body.should == "new response"
169
+ end
170
+
171
+ it "sets @body to the body string" do
172
+ EphemeralResponse::Fixture.respond_to(fixture.uri, request, nil) do
173
+ stub(:body => :hello_world)
174
+ end
175
+ response = EphemeralResponse::Fixture.fixtures[fixture.identifier].response
176
+ response.instance_variable_get(:@body).should == "hello_world"
153
177
  end
154
178
 
155
179
  it "saves the fixture" do
156
- EphemeralResponse::Fixture.respond_to(fixture.uri, request) do
157
- "new response"
180
+ EphemeralResponse::Fixture.respond_to(fixture.uri, request, nil) do
181
+ stub(:body => "new response")
158
182
  end
159
183
  File.exists?(fixture.path).should be_true
160
184
  end
@@ -293,6 +317,19 @@ describe EphemeralResponse::Fixture do
293
317
  end
294
318
  end
295
319
 
320
+ describe "#new?" do
321
+ it "is new when the fixture hasn't been registered" do
322
+ fixture = EphemeralResponse::Fixture.new uri, request
323
+ fixture.should be_new
324
+ end
325
+
326
+ it "isn't new when the fixture has been registered" do
327
+ fixture = EphemeralResponse::Fixture.new uri, request
328
+ EphemeralResponse::Fixture.register(fixture)
329
+ fixture.should_not be_new
330
+ end
331
+ end
332
+
296
333
  describe "#file_name" do
297
334
  it "chops off the starting slash when accessing '/'" do
298
335
  uri = URI.parse("http://example.com/")
@@ -4,7 +4,7 @@ describe Net::HTTP do
4
4
  subject { Net::HTTP.new('example.com') }
5
5
  let(:request) { Net::HTTP::Get.new("/foo?q=1") }
6
6
  let(:uri) { URI.parse("http://example.com/foo?q=1") }
7
- let(:response) { "Hello" }
7
+ let(:response) { OpenStruct.new(:body => "Hello") }
8
8
 
9
9
  before do
10
10
  subject.stub(:connect_without_ephemeral_response)
@@ -63,7 +63,14 @@ describe Net::HTTP do
63
63
 
64
64
  context "fixture exists" do
65
65
  before do
66
- EphemeralResponse::Fixture.stub(:respond_to => response)
66
+ fixture = EphemeralResponse::Fixture.new(uri, request) do |f|
67
+ f.response = response
68
+ end
69
+ fixture.register
70
+ end
71
+
72
+ after do
73
+ clear_fixtures
67
74
  end
68
75
 
69
76
  it "does not connect" do
@@ -75,6 +82,12 @@ describe Net::HTTP do
75
82
  subject.should_not_receive(:request_without_ephemeral_response).with(request, nil).and_return(response)
76
83
  subject.request(request)
77
84
  end
85
+
86
+ it "yields the response to the block" do
87
+ subject.request(request) do |response|
88
+ response.should == response
89
+ end
90
+ end
78
91
  end
79
92
 
80
93
  context "connection not started" do
@@ -11,6 +11,7 @@ describe EphemeralResponse do
11
11
  describe ".deactivate" do
12
12
  before do
13
13
  Net::HTTP.stub(:alias_method)
14
+ Net::HTTPResponse.stub(:alias_method)
14
15
  end
15
16
 
16
17
  it "restores the original connection method" do
@@ -23,16 +24,26 @@ describe EphemeralResponse do
23
24
  EphemeralResponse.deactivate
24
25
  end
25
26
 
27
+ it "restores #procdest" do
28
+ Net::HTTPResponse.should_receive(:alias_method).with(:procdest, :procdest_without_ephemeral_response)
29
+ EphemeralResponse.deactivate
30
+ end
31
+
32
+ it "restores #read_body" do
33
+ Net::HTTPResponse.should_receive(:alias_method).with(:read_body, :read_body_without_ephemeral_response)
34
+ EphemeralResponse.deactivate
35
+ end
36
+
26
37
  it "removes #generate_uri" do
27
- Net::HTTP.instance_methods.should include('generate_uri')
38
+ Net::HTTP.method_defined?(:generate_uri).should be_true
28
39
  EphemeralResponse.deactivate
29
- Net::HTTP.instance_methods.should_not include('generate_uri')
40
+ Net::HTTP.method_defined?(:generate_uri).should be_false
30
41
  end
31
42
 
32
43
  it "removes #uri" do
33
- Net::HTTP.instance_methods.should include('uri')
44
+ Net::HTTP.method_defined?(:uri).should be_true
34
45
  EphemeralResponse.deactivate
35
- Net::HTTP.instance_methods.should_not include('uri')
46
+ Net::HTTP.method_defined?(:uri).should be_false
36
47
  end
37
48
  end
38
49
 
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+ require 'open-uri'
3
+
4
+ describe "Read Body Compatibility" do
5
+ include FakeFS::SpecHelpers
6
+
7
+ after do
8
+ clear_fixtures
9
+ end
10
+
11
+ let(:uri) { URI.parse('http://example.com/') }
12
+
13
+ def http
14
+ Net::HTTP.new uri.host, uri.port
15
+ end
16
+
17
+ def get
18
+ Net::HTTP::Get.new '/'
19
+ end
20
+
21
+ def send_request(req, data=nil)
22
+ http.start {|h| h.request(req, data) }
23
+ end
24
+
25
+ context "open-uri" do
26
+ it "generates a fixture, then uses the fixture" do
27
+ real_response = uri.open.read
28
+ fixture = EphemeralResponse::Fixture.find(uri, get)
29
+ File.exists?(fixture.path).should be_true
30
+ fixture_response = send_request(get).body
31
+ real_response.should == fixture_response
32
+ end
33
+ end
34
+
35
+ context "Net::HTTP#get" do
36
+ it "generates a fixture, then uses the fixture" do
37
+ real_response = nil
38
+ http.get('/') {|s| real_response = s}
39
+ fixture = EphemeralResponse::Fixture.find(uri, get)
40
+ File.exists?(fixture.path).should be_true
41
+ fixture_response = send_request(get).body
42
+ real_response.should == fixture_response
43
+ end
44
+ end
45
+
46
+ context "Net::HTTP.post" do
47
+ it "generates a fixture, then uses the fixture" do
48
+ post = Net::HTTP::Post.new('/')
49
+ real_response = nil
50
+ http.post('/', 'foo=bar') {|s| real_response = s}
51
+ fixture = EphemeralResponse::Fixture.find(uri, post)
52
+ File.exists?(fixture.path).should be_true
53
+ fixture_response = send_request(post, 'foo=bar').body
54
+ real_response.should == fixture_response
55
+ end
56
+ end
57
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,10 +4,14 @@ require 'ephemeral_response'
4
4
  require 'fakefs/safe'
5
5
  require 'fakefs/spec_helpers'
6
6
  require 'spec/autorun'
7
- Dir.glob("spec/support/*.rb") {|f| require f}
7
+
8
+ Dir.glob("spec/support/*.rb") {|f| require File.expand_path(f, '.')}
8
9
 
9
10
  Spec::Runner.configure do |config|
10
11
  config.include ClearFixtures
12
+ config.before(:suite) do
13
+ ClearFixtures.clear_fixtures
14
+ end
11
15
  config.before(:each) do
12
16
  EphemeralResponse::Configuration.reset
13
17
  EphemeralResponse.activate
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sandro Turriate
@@ -15,13 +15,29 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-29 00:00:00 -04:00
18
+ date: 2010-07-30 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: jeweler
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 0
33
+ version: 1.4.0
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
25
41
  requirements:
26
42
  - - ">="
27
43
  - !ruby/object:Gem::Version
@@ -31,11 +47,12 @@ dependencies:
31
47
  - 9
32
48
  version: 1.2.9
33
49
  type: :development
34
- version_requirements: *id001
50
+ version_requirements: *id002
35
51
  - !ruby/object:Gem::Dependency
36
52
  name: yard
37
53
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
39
56
  requirements:
40
57
  - - ">="
41
58
  - !ruby/object:Gem::Version
@@ -45,11 +62,12 @@ dependencies:
45
62
  - 0
46
63
  version: 0.5.0
47
64
  type: :development
48
- version_requirements: *id002
65
+ version_requirements: *id003
49
66
  - !ruby/object:Gem::Dependency
50
67
  name: fakefs
51
68
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
53
71
  requirements:
54
72
  - - ">="
55
73
  - !ruby/object:Gem::Version
@@ -59,11 +77,12 @@ dependencies:
59
77
  - 1
60
78
  version: 0.2.1
61
79
  type: :development
62
- version_requirements: *id003
80
+ version_requirements: *id004
63
81
  - !ruby/object:Gem::Dependency
64
82
  name: unicorn
65
83
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
67
86
  requirements:
68
87
  - - ">="
69
88
  - !ruby/object:Gem::Version
@@ -73,7 +92,7 @@ dependencies:
73
92
  - 0
74
93
  version: 1.0.0
75
94
  type: :development
76
- version_requirements: *id004
95
+ version_requirements: *id005
77
96
  description: "\n Save HTTP responses to give your tests a hint of reality.\n Responses are saved into your fixtures directory and are used for subsequent web requests until they expire.\n "
78
97
  email: sandro.turriate@gmail.com
79
98
  executables: []
@@ -85,12 +104,15 @@ extra_rdoc_files:
85
104
  files:
86
105
  - .document
87
106
  - .gitignore
107
+ - Gemfile
88
108
  - History.markdown
89
109
  - MIT_LICENSE
90
110
  - README.markdown
91
111
  - Rakefile
92
112
  - VERSION
113
+ - ephemeral_response.gemspec
93
114
  - examples/custom_cache_key.rb
115
+ - examples/open_uri_compatibility.rb
94
116
  - examples/simple_benchmark.rb
95
117
  - examples/white_list.rb
96
118
  - lib/ephemeral_response.rb
@@ -104,6 +126,7 @@ files:
104
126
  - spec/ephemeral_response_spec.rb
105
127
  - spec/integration/custom_identifier_spec.rb
106
128
  - spec/integration/normal_flow_spec.rb
129
+ - spec/integration/read_body_compatibility_spec.rb
107
130
  - spec/integration/unique_fixtures_spec.rb
108
131
  - spec/integration/white_list_spec.rb
109
132
  - spec/spec.opts
@@ -122,6 +145,7 @@ rdoc_options:
122
145
  require_paths:
123
146
  - lib
124
147
  required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
125
149
  requirements:
126
150
  - - ">="
127
151
  - !ruby/object:Gem::Version
@@ -129,6 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
153
  - 0
130
154
  version: "0"
131
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
132
157
  requirements:
133
158
  - - ">="
134
159
  - !ruby/object:Gem::Version
@@ -138,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
163
  requirements: []
139
164
 
140
165
  rubyforge_project:
141
- rubygems_version: 1.3.6
166
+ rubygems_version: 1.3.7
142
167
  signing_key:
143
168
  specification_version: 3
144
169
  summary: Save HTTP responses to give your tests a hint of reality.
@@ -149,6 +174,7 @@ test_files:
149
174
  - spec/ephemeral_response_spec.rb
150
175
  - spec/integration/custom_identifier_spec.rb
151
176
  - spec/integration/normal_flow_spec.rb
177
+ - spec/integration/read_body_compatibility_spec.rb
152
178
  - spec/integration/unique_fixtures_spec.rb
153
179
  - spec/integration/white_list_spec.rb
154
180
  - spec/spec_helper.rb
@@ -157,5 +183,6 @@ test_files:
157
183
  - spec/support/rack_reflector.rb
158
184
  - spec/support/time.rb
159
185
  - examples/custom_cache_key.rb
186
+ - examples/open_uri_compatibility.rb
160
187
  - examples/simple_benchmark.rb
161
188
  - examples/white_list.rb