rack-test 0.6.0 → 0.6.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/Gemfile CHANGED
@@ -3,3 +3,4 @@ source :rubygems
3
3
  gem 'rspec'
4
4
  gem "rack"
5
5
  gem "sinatra"
6
+ gem 'rake'
@@ -2,19 +2,20 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  diff-lcs (1.1.2)
5
- rack (1.2.2)
6
- rspec (2.3.0)
7
- rspec-core (~> 2.3.0)
8
- rspec-expectations (~> 2.3.0)
9
- rspec-mocks (~> 2.3.0)
10
- rspec-core (2.3.1)
11
- rspec-expectations (2.3.0)
5
+ rack (1.3.2)
6
+ rake (0.9.2)
7
+ rspec (2.6.0)
8
+ rspec-core (~> 2.6.0)
9
+ rspec-expectations (~> 2.6.0)
10
+ rspec-mocks (~> 2.6.0)
11
+ rspec-core (2.6.4)
12
+ rspec-expectations (2.6.0)
12
13
  diff-lcs (~> 1.1.2)
13
- rspec-mocks (2.3.0)
14
- sinatra (1.2.3)
14
+ rspec-mocks (2.6.0)
15
+ sinatra (1.2.6)
15
16
  rack (~> 1.1)
16
17
  tilt (< 2.0, >= 1.2.2)
17
- tilt (1.2.2)
18
+ tilt (1.3.2)
18
19
 
19
20
  PLATFORMS
20
21
  java
@@ -22,5 +23,6 @@ PLATFORMS
22
23
 
23
24
  DEPENDENCIES
24
25
  rack
26
+ rake
25
27
  rspec
26
28
  sinatra
@@ -1,3 +1,11 @@
1
+ == 0.6.1 / 2011-07-27
2
+
3
+ * Bug fixes
4
+
5
+ * Fix support for params with arrays in multipart forms (Joel Chippindale)
6
+ * Add respond_to? to Rack::Test::UploadedFile to match method_missing (Josh Nichols)
7
+ * Set the Referer header on requests issued by follow_redirect! (Ryan Bigg)
8
+
1
9
  == 0.6.0 / 2011-05-03
2
10
 
3
11
  * Bug fixes
@@ -9,7 +9,7 @@ require "rack/test/uploaded_file"
9
9
 
10
10
  module Rack
11
11
  module Test
12
- VERSION = "0.6.0"
12
+ VERSION = "0.6.1"
13
13
 
14
14
  DEFAULT_HOST = "example.org"
15
15
  MULTIPART_BOUNDARY = "----------XnJLe9ZIbbGUYtzPQJ16u1"
@@ -153,14 +153,15 @@ module Rack
153
153
  end
154
154
 
155
155
  # Rack::Test will not follow any redirects automatically. This method
156
- # will follow the redirect returned in the last response. If the last
157
- # response was not a redirect, an error will be raised.
156
+ # will follow the redirect returned (including setting the Referer header
157
+ # on the new request) in the last response. If the last response was not
158
+ # a redirect, an error will be raised.
158
159
  def follow_redirect!
159
160
  unless last_response.redirect?
160
161
  raise Error.new("Last response was not a redirect. Cannot follow_redirect!")
161
162
  end
162
163
 
163
- get(last_response["Location"])
164
+ get(last_response["Location"], {}, { "HTTP_REFERER" => last_request.url })
164
165
  end
165
166
 
166
167
  private
@@ -40,6 +40,10 @@ module Rack
40
40
  @tempfile.__send__(method_name, *args, &block)
41
41
  end
42
42
 
43
+ def respond_to?(method_name, include_private = false) #:nodoc:
44
+ @tempfile.respond_to?(method_name, include_private) || super
45
+ end
46
+
43
47
  end
44
48
 
45
49
  end
@@ -103,12 +103,17 @@ module Rack
103
103
  end
104
104
 
105
105
  def build_primitive_part(parameter_name, value)
106
+ unless value.is_a? Array
107
+ value = [value]
108
+ end
109
+ value.map do |v|
106
110
  <<-EOF
107
111
  --#{MULTIPART_BOUNDARY}\r
108
112
  Content-Disposition: form-data; name="#{parameter_name}"\r
109
113
  \r
110
- #{value}\r
114
+ #{v}\r
111
115
  EOF
116
+ end.join
112
117
  end
113
118
 
114
119
  def build_file_part(parameter_name, uploaded_file)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rack-test}
5
- s.version = "0.6.0"
5
+ s.version = "0.6.1"
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{2011-05-03}
9
+ s.date = %q{2011-07-27}
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
@@ -41,6 +41,7 @@ request helpers feature.}
41
41
  "spec/rack/test/cookie_spec.rb",
42
42
  "spec/rack/test/digest_auth_spec.rb",
43
43
  "spec/rack/test/multipart_spec.rb",
44
+ "spec/rack/test/uploaded_file_spec.rb",
44
45
  "spec/rack/test/utils_spec.rb",
45
46
  "spec/rack/test_spec.rb",
46
47
  "spec/spec_helper.rb",
@@ -57,6 +58,7 @@ request helpers feature.}
57
58
  "spec/rack/test/cookie_spec.rb",
58
59
  "spec/rack/test/digest_auth_spec.rb",
59
60
  "spec/rack/test/multipart_spec.rb",
61
+ "spec/rack/test/uploaded_file_spec.rb",
60
62
  "spec/rack/test/utils_spec.rb",
61
63
  "spec/rack/test_spec.rb",
62
64
  "spec/spec_helper.rb",
@@ -42,10 +42,8 @@ describe Rack::Test::Session do
42
42
  end
43
43
 
44
44
  it "sends params with arrays" do
45
- pending "FIXME: should work the same with and without multipart" do
46
- post "/", "photo" => uploaded_file, "foo" => ["1", "2"]
47
- last_request.POST["foo"].should == ["1", "2"]
48
- end
45
+ post "/", "photo" => uploaded_file, "foo" => ["1", "2"]
46
+ last_request.POST["foo"].should == ["1", "2"]
49
47
  end
50
48
 
51
49
  it "sends params with encoding sensitive values" do
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Rack::Test::UploadedFile do
4
+ def test_file_path
5
+ File.dirname(__FILE__) + "/../../fixtures/foo.txt"
6
+ end
7
+
8
+ it "responds to things that Tempfile responds to" do
9
+ uploaded_file = Rack::Test::UploadedFile.new(test_file_path)
10
+
11
+ uploaded_file.should respond_to(:close)
12
+ uploaded_file.should respond_to(:close!)
13
+ uploaded_file.should respond_to(:delete)
14
+ uploaded_file.should respond_to(:length)
15
+ uploaded_file.should respond_to(:open)
16
+ uploaded_file.should respond_to(:path)
17
+ uploaded_file.should respond_to(:size)
18
+ uploaded_file.should respond_to(:unlink)
19
+ uploaded_file.should respond_to(:read)
20
+ end
21
+
22
+ end
@@ -89,7 +89,7 @@ describe Rack::Test::Utils do
89
89
 
90
90
  it "builds nested multipart bodies" do
91
91
  files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
92
- data = build_multipart("people" => [{"submit-name" => "Larry", "files" => files}])
92
+ data = build_multipart("people" => [{"submit-name" => "Larry", "files" => files}], "foo" => ['1', '2'])
93
93
 
94
94
  options = {
95
95
  "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
@@ -101,6 +101,7 @@ describe Rack::Test::Utils do
101
101
  check params["people"][0]["submit-name"].should == "Larry"
102
102
  check params["people"][0]["files"][:filename].should == "foo.txt"
103
103
  params["people"][0]["files"][:tempfile].read.should == "bar\n"
104
+ check params["foo"].should == ["1", "2"]
104
105
  end
105
106
 
106
107
  it "returns nil if no UploadedFiles were used" do
@@ -228,7 +228,7 @@ describe Rack::Test::Session do
228
228
 
229
229
  last_request.env["CONTENT_TYPE"].should == "application/json"
230
230
  end
231
-
231
+
232
232
  it "sets a Host to be sent with requests" do
233
233
  header "Host", "www.example.ua"
234
234
  request "/"
@@ -292,6 +292,7 @@ describe Rack::Test::Session do
292
292
 
293
293
  last_response.should_not be_redirect
294
294
  last_response.body.should == "You've been redirected"
295
+ last_request.env["HTTP_REFERER"].should eql("http://example.org/redirect")
295
296
  end
296
297
 
297
298
  it "does not include params when following the redirect" do
@@ -9,7 +9,7 @@ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
9
9
  require "rack/test"
10
10
  require File.dirname(__FILE__) + "/fixtures/fake_app"
11
11
 
12
- Rspec.configure do |config|
12
+ RSpec.configure do |config|
13
13
  config.mock_with :rspec
14
14
  config.include Rack::Test::Methods
15
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bryan Helmkamp
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-03 00:00:00 -04:00
18
+ date: 2011-07-27 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - spec/rack/test/cookie_spec.rb
72
72
  - spec/rack/test/digest_auth_spec.rb
73
73
  - spec/rack/test/multipart_spec.rb
74
+ - spec/rack/test/uploaded_file_spec.rb
74
75
  - spec/rack/test/utils_spec.rb
75
76
  - spec/rack/test_spec.rb
76
77
  - spec/spec_helper.rb
@@ -115,6 +116,7 @@ test_files:
115
116
  - spec/rack/test/cookie_spec.rb
116
117
  - spec/rack/test/digest_auth_spec.rb
117
118
  - spec/rack/test/multipart_spec.rb
119
+ - spec/rack/test/uploaded_file_spec.rb
118
120
  - spec/rack/test/utils_spec.rb
119
121
  - spec/rack/test_spec.rb
120
122
  - spec/spec_helper.rb