josh-rack-test 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,11 +1,15 @@
1
- == Git
1
+ == 0.4.2 / 2009-09-01
2
2
 
3
3
  * Minor enhancements
4
4
 
5
+ * Merge in rack/master's build_multipart method which covers additional cases
6
+ * Accept raw :params string input and merge it with the query string
5
7
  * Stringify and upcase request method (e.g. :post => "POST") (Josh Peek)
6
8
 
7
9
  * Bug fixes
8
10
 
11
+ * Properly convert hashes with nil values (e.g. :foo => nil becomes simply "foo", not "foo=")
12
+ * Prepend a slash to the URI path if it doesn't start with one (Josh Peek)
9
13
  * Requiring Rack-Test never modifies the Ruby load path anymore (Josh Peek)
10
14
  * Fixed using multiple cookies in a string on Ruby 1.8 (Tuomas Kareinen and Hermanni Hyytiälä)
11
15
 
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.4.1"
12
+ VERSION = "0.4.2"
13
13
 
14
14
  DEFAULT_HOST = "example.org"
15
15
  MULTIPART_BOUNDARY = "----------XnJLe9ZIbbGUYtzPQJ16u1"
@@ -141,6 +141,7 @@ module Rack
141
141
 
142
142
  def env_for(path, env)
143
143
  uri = URI.parse(path)
144
+ uri.path = "/#{uri.path}" unless uri.path[0] == ?/
144
145
  uri.host ||= @default_host
145
146
 
146
147
  env = default_env.merge(env)
@@ -154,8 +155,8 @@ module Rack
154
155
 
155
156
  if env["REQUEST_METHOD"] == "GET"
156
157
  params = env[:params] || {}
158
+ params = parse_nested_query(params) if params.is_a?(String)
157
159
  params.update(parse_query(uri.query))
158
-
159
160
  uri.query = build_nested_query(params)
160
161
  elsif !env.has_key?(:input)
161
162
  env["CONTENT_TYPE"] ||= "application/x-www-form-urlencoded"
@@ -173,6 +174,8 @@ module Rack
173
174
  end
174
175
  end
175
176
 
177
+ env.delete(:params)
178
+
176
179
  if env.has_key?(:cookie)
177
180
  set_cookie(env.delete(:cookie), uri)
178
181
  end
@@ -14,6 +14,8 @@ module Rack
14
14
  value.map do |k, v|
15
15
  build_nested_query(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
16
16
  end.join("&")
17
+ when NilClass
18
+ prefix.to_s
17
19
  else
18
20
  "#{prefix}=#{escape(value)}"
19
21
  end
data/rack-test.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-test}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bryan Helmkamp"]
12
- s.date = %q{2009-08-06}
12
+ s.date = %q{2009-09-01}
13
13
  s.email = %q{bryan@brynary.com}
14
14
  s.extra_rdoc_files = [
15
15
  "MIT-LICENSE.txt",
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  s.rdoc_options = ["--charset=UTF-8"]
47
47
  s.require_paths = ["lib"]
48
48
  s.rubyforge_project = %q{rack-test}
49
- s.rubygems_version = %q{1.3.4}
49
+ s.rubygems_version = %q{1.3.5}
50
50
  s.summary = %q{Simple testing API built on Rack}
51
51
  s.test_files = [
52
52
  "spec/fixtures/fake_app.rb",
@@ -8,8 +8,12 @@ describe Rack::Test::Utils do
8
8
  build_nested_query("").should == "="
9
9
  end
10
10
 
11
- it "converts nil to =" do
12
- build_nested_query(nil).should == "="
11
+ it "converts nil to an empty string" do
12
+ build_nested_query(nil).should == ""
13
+ end
14
+
15
+ it "converts hashes with nil values" do
16
+ build_nested_query(:a => nil).should == "a"
13
17
  end
14
18
 
15
19
  it "converts hashes" do
@@ -71,11 +71,41 @@ describe Rack::Test::Session do
71
71
  last_response.body.should be_empty
72
72
  end
73
73
 
74
- it "stringify and upcases method" do
74
+ it "allows passing :input in for POSTs" do
75
75
  request "/", :method => :post, :input => "foo"
76
76
  last_request.env["rack.input"].read.should == "foo"
77
77
  end
78
78
 
79
+ it "converts method names to a uppercase strings" do
80
+ request "/", :method => :put
81
+ last_request.env["REQUEST_METHOD"].should == "PUT"
82
+ end
83
+
84
+ it "prepends a slash to the URI path" do
85
+ request "foo"
86
+ last_request.env["PATH_INFO"].should == "/foo"
87
+ end
88
+
89
+ it "accepts params and builds query strings for GET requests" do
90
+ request "/foo?baz=2", :params => {:foo => {:bar => "1"}}
91
+ last_request.env["QUERY_STRING"].should == "baz=2&foo[bar]=1"
92
+ end
93
+
94
+ it "accepts raw input in params for GET requests" do
95
+ request "/foo?baz=2", :params => "foo[bar]=1"
96
+ last_request.env["QUERY_STRING"].should == "baz=2&foo[bar]=1"
97
+ end
98
+
99
+ it "accepts params and builds url encoded params for POST requests" do
100
+ request "/foo", :method => :post, :params => {:foo => {:bar => "1"}}
101
+ last_request.env["rack.input"].read.should == "foo[bar]=1"
102
+ end
103
+
104
+ it "accepts raw input in params for POST requests" do
105
+ request "/foo", :method => :post, :params => "foo[bar]=1"
106
+ last_request.env["rack.input"].read.should == "foo[bar]=1"
107
+ end
108
+
79
109
  context "when input is given" do
80
110
  it "should send the input" do
81
111
  request "/", :method => "POST", :input => "foo"
@@ -110,6 +140,11 @@ describe Rack::Test::Session do
110
140
  end
111
141
 
112
142
  context "when the URL is https://" do
143
+ it "sets rack.url_scheme to https" do
144
+ get "https://example.org/"
145
+ last_request.env["rack.url_scheme"].should == "https"
146
+ end
147
+
113
148
  it "sets SERVER_PORT to 443" do
114
149
  get "https://example.org/"
115
150
  last_request.env["SERVER_PORT"].should == "443"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josh-rack-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.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-08-06 00:00:00 -07:00
12
+ date: 2009-09-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15