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 +7 -0
- data/lib/rack/mock_session.rb +2 -1
- data/lib/rack/test.rb +1 -1
- data/lib/rack/test/cookie_jar.rb +1 -0
- data/rack-test.gemspec +2 -2
- data/spec/rack/test_spec.rb +37 -7
- metadata +2 -2
data/History.txt
CHANGED
data/lib/rack/mock_session.rb
CHANGED
@@ -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
data/lib/rack/test/cookie_jar.rb
CHANGED
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.
|
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-
|
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
|
data/spec/rack/test_spec.rb
CHANGED
@@ -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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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.
|
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-
|
12
|
+
date: 2009-11-13 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|