rack-test 0.5.1 → 0.5.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/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.5.2 / 2009-11-13
2
+
3
+ * Bug fixes
4
+
5
+ * Call close on response body after iteration, not before (Simon Rozet)
6
+ * Add missing require for time in cookie_jar.rb (Jerry West)
7
+
1
8
  == 0.5.1 / 2009-10-27
2
9
 
3
10
  * Bug fixes
@@ -28,9 +28,10 @@ module Rack
28
28
  env["HTTP_COOKIE"] ||= cookie_jar.for(uri)
29
29
  @last_request = Rack::Request.new(env)
30
30
  status, headers, body = @app.call(@last_request.env)
31
- body.close if body.respond_to?(:close)
32
31
 
33
32
  @last_response = MockResponse.new(status, headers, body, env["rack.errors"].flush)
33
+ body.close if body.respond_to?(:close)
34
+
34
35
  cookie_jar.merge(last_response.headers["Set-Cookie"], uri)
35
36
 
36
37
  @after_request.each { |hook| hook.call }
data/lib/rack/test.rb CHANGED
@@ -9,7 +9,7 @@ require "rack/test/uploaded_file"
9
9
 
10
10
  module Rack
11
11
  module Test
12
- VERSION = "0.5.1"
12
+ VERSION = "0.5.2"
13
13
 
14
14
  DEFAULT_HOST = "example.org"
15
15
  MULTIPART_BOUNDARY = "----------XnJLe9ZIbbGUYtzPQJ16u1"
@@ -1,4 +1,5 @@
1
1
  require "uri"
2
+ require "time"
2
3
 
3
4
  module Rack
4
5
  module Test
data/rack-test.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rack-test}
5
- s.version = "0.5.1"
5
+ s.version = "0.5.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bryan Helmkamp"]
9
- s.date = %q{2009-10-27}
9
+ s.date = %q{2009-11-13}
10
10
  s.description = %q{Rack::Test is a small, simple testing API for Rack apps. It can be used on its
11
11
  own or as a reusable starting point for Web frameworks and testing libraries
12
12
  to build on. Most of its initial functionality is an extraction of Merb 1.0's
@@ -106,13 +106,43 @@ describe Rack::Test::Session do
106
106
  last_request.env["rack.input"].read.should == "foo[bar]=1"
107
107
  end
108
108
 
109
- it "closes response's body" do
110
- body = "Hello, World!"
111
- body.should_receive(:close)
112
- app = lambda {|env|
113
- [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, body]
114
- }
115
- Rack::Test::Session.new(Rack::MockSession.new(app)).request("/")
109
+ context "when the response body responds_to?(:close)" do
110
+ class CloseableBody
111
+ def initialize
112
+ @closed = false
113
+ end
114
+
115
+ def each
116
+ return if @closed
117
+ yield "Hello, World!"
118
+ end
119
+
120
+ def close
121
+ @closed = true
122
+ end
123
+ end
124
+
125
+ it "closes response's body" do
126
+ body = CloseableBody.new
127
+ body.should_receive(:close)
128
+
129
+ app = lambda do |env|
130
+ [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, body]
131
+ end
132
+
133
+ session = Rack::Test::Session.new(Rack::MockSession.new(app))
134
+ session.request("/")
135
+ end
136
+
137
+ it "closes response's body after iteration" do
138
+ app = lambda do |env|
139
+ [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, CloseableBody.new]
140
+ end
141
+
142
+ session = Rack::Test::Session.new(Rack::MockSession.new(app))
143
+ session.request("/")
144
+ session.last_response.body.should == "Hello, World!"
145
+ end
116
146
  end
117
147
 
118
148
  context "when input is given" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-27 00:00:00 -04:00
12
+ date: 2009-11-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency