rack-test 0.5.4 → 0.5.5
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 +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +23 -0
- data/History.txt +8 -1
- data/Rakefile +16 -22
- data/lib/rack/test.rb +3 -1
- data/lib/rack/test/utils.rb +2 -1
- data/rack-test.gemspec +12 -5
- data/spec/fixtures/fake_app.rb +1 -0
- data/spec/rack/test/cookie_spec.rb +0 -5
- data/spec/rack/test/digest_auth_spec.rb +0 -8
- data/spec/rack/test/multipart_spec.rb +13 -0
- data/spec/rack/test/utils_spec.rb +1 -1
- data/spec/rack/test_spec.rb +2 -2
- data/spec/spec_helper.rb +18 -4
- data/spec/support/core_ext/string.rb +12 -0
- data/spec/support/matchers/body.rb +9 -0
- data/spec/support/matchers/challenge.rb +11 -0
- metadata +12 -5
- data/spec/spec.opts +0 -2
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rack (1.2.1)
|
6
|
+
rspec (2.0.0.beta.20)
|
7
|
+
rspec-core (= 2.0.0.beta.20)
|
8
|
+
rspec-expectations (= 2.0.0.beta.20)
|
9
|
+
rspec-mocks (= 2.0.0.beta.20)
|
10
|
+
rspec-core (2.0.0.beta.20)
|
11
|
+
rspec-expectations (2.0.0.beta.20)
|
12
|
+
diff-lcs (>= 1.1.2)
|
13
|
+
rspec-mocks (2.0.0.beta.20)
|
14
|
+
sinatra (1.0)
|
15
|
+
rack (>= 1.0)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
rack
|
22
|
+
rspec (>= 2.0.0.beta.15)
|
23
|
+
sinatra
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,31 +1,25 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
|
3
|
-
begin
|
4
|
-
require "spec/rake/spectask"
|
5
|
-
rescue LoadError
|
6
|
-
desc "Run specs"
|
7
|
-
task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
|
8
|
-
else
|
9
|
-
Spec::Rake::SpecTask.new do |t|
|
10
|
-
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
11
|
-
t.libs << 'lib'
|
12
|
-
t.libs << 'spec'
|
13
|
-
t.warning = true
|
14
|
-
end
|
15
3
|
|
16
|
-
|
4
|
+
require 'rspec/core'
|
5
|
+
require "rspec/core/rake_task"
|
17
6
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
t.libs << 'lib'
|
22
|
-
t.libs << 'spec'
|
23
|
-
t.warning = true
|
24
|
-
t.rcov = true
|
25
|
-
t.rcov_opts = ['-x spec']
|
26
|
-
end
|
7
|
+
RSpec::Core::RakeTask.new do |t|
|
8
|
+
t.pattern = "./**/*_spec.rb"
|
9
|
+
t.ruby_opts = "-w"
|
27
10
|
end
|
28
11
|
|
12
|
+
task :default => :spec
|
13
|
+
|
14
|
+
# desc "Run all specs in spec directory with RCov"
|
15
|
+
# RSpec::Core::RakeTask.new(:rcov) do |t|
|
16
|
+
# t.libs << 'lib'
|
17
|
+
# t.libs << 'spec'
|
18
|
+
# t.warning = true
|
19
|
+
# t.rcov = true
|
20
|
+
# t.rcov_opts = ['-x spec']
|
21
|
+
# end
|
22
|
+
|
29
23
|
desc "Generate RDoc"
|
30
24
|
task :docs do
|
31
25
|
FileUtils.rm_rf("doc")
|
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.
|
12
|
+
VERSION = "0.5.5"
|
13
13
|
|
14
14
|
DEFAULT_HOST = "example.org"
|
15
15
|
MULTIPART_BOUNDARY = "----------XnJLe9ZIbbGUYtzPQJ16u1"
|
@@ -161,6 +161,8 @@ module Rack
|
|
161
161
|
uri.path = "/#{uri.path}" unless uri.path[0] == ?/
|
162
162
|
uri.host ||= @default_host
|
163
163
|
|
164
|
+
env["HTTP_HOST"] = [uri.host, uri.port].compact.join(":")
|
165
|
+
|
164
166
|
env = default_env.merge(env)
|
165
167
|
|
166
168
|
env.update("HTTPS" => "on") if URI::HTTPS === uri
|
data/lib/rack/test/utils.rb
CHANGED
@@ -95,7 +95,8 @@ module Rack
|
|
95
95
|
end.join
|
96
96
|
|
97
97
|
else
|
98
|
-
build_primitive_part(name, value)
|
98
|
+
primitive_part = build_primitive_part(name, value)
|
99
|
+
primitive_part.encoding_aware? ? primitive_part.force_encoding('BINARY') : primitive_part
|
99
100
|
end
|
100
101
|
|
101
102
|
}.join + "--#{MULTIPART_BOUNDARY}--\r"
|
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.5"
|
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{2010-
|
9
|
+
s.date = %q{2010-09-22}
|
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
|
@@ -19,6 +19,8 @@ request helpers feature.}
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
22
24
|
"History.txt",
|
23
25
|
"MIT-LICENSE.txt",
|
24
26
|
"README.rdoc",
|
@@ -41,8 +43,10 @@ request helpers feature.}
|
|
41
43
|
"spec/rack/test/multipart_spec.rb",
|
42
44
|
"spec/rack/test/utils_spec.rb",
|
43
45
|
"spec/rack/test_spec.rb",
|
44
|
-
"spec/
|
45
|
-
"spec/
|
46
|
+
"spec/spec_helper.rb",
|
47
|
+
"spec/support/core_ext/string.rb",
|
48
|
+
"spec/support/matchers/body.rb",
|
49
|
+
"spec/support/matchers/challenge.rb"
|
46
50
|
]
|
47
51
|
s.homepage = %q{http://github.com/brynary/rack-test}
|
48
52
|
s.require_paths = ["lib"]
|
@@ -56,7 +60,10 @@ request helpers feature.}
|
|
56
60
|
"spec/rack/test/multipart_spec.rb",
|
57
61
|
"spec/rack/test/utils_spec.rb",
|
58
62
|
"spec/rack/test_spec.rb",
|
59
|
-
"spec/spec_helper.rb"
|
63
|
+
"spec/spec_helper.rb",
|
64
|
+
"spec/support/core_ext/string.rb",
|
65
|
+
"spec/support/matchers/body.rb",
|
66
|
+
"spec/support/matchers/challenge.rb"
|
60
67
|
]
|
61
68
|
|
62
69
|
if s.respond_to? :specification_version then
|
data/spec/fixtures/fake_app.rb
CHANGED
@@ -12,14 +12,6 @@ describe Rack::Test::Session do
|
|
12
12
|
app
|
13
13
|
end
|
14
14
|
|
15
|
-
def be_challenge
|
16
|
-
simple_matcher "a HTTP Digest challenge response" do |response|
|
17
|
-
response.status == 401 &&
|
18
|
-
response['WWW-Authenticate'] =~ /^Digest / &&
|
19
|
-
response.body.empty?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
15
|
it 'incorrectly authenticates GETs' do
|
24
16
|
digest_authorize 'foo', 'bar'
|
25
17
|
get '/'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Rack::Test::Session do
|
@@ -51,6 +53,17 @@ describe Rack::Test::Session do
|
|
51
53
|
last_request.POST["foo"].should == "bar? baz"
|
52
54
|
end
|
53
55
|
|
56
|
+
it "sends params encoded as ISO-8859-1" do
|
57
|
+
post "/", "photo" => uploaded_file, "foo" => "bar", "utf8" => "☃"
|
58
|
+
last_request.POST["foo"].should == "bar"
|
59
|
+
|
60
|
+
if last_request.POST["utf8"].encoding_aware?
|
61
|
+
last_request.POST["utf8"].should == "\xE2\x98\x83".force_encoding("BINARY")
|
62
|
+
else
|
63
|
+
last_request.POST["utf8"].should == "\xE2\x98\x83"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
54
67
|
it "sends params with parens in names" do
|
55
68
|
post "/", "photo" => uploaded_file, "foo(1i)" => "bar"
|
56
69
|
last_request.POST["foo(1i)"].should == "bar"
|
@@ -103,7 +103,7 @@ describe Rack::Test::Utils do
|
|
103
103
|
params["people"][0]["files"][:tempfile].read.should == "bar\n"
|
104
104
|
end
|
105
105
|
|
106
|
-
it "
|
106
|
+
it "returns nil if no UploadedFiles were used" do
|
107
107
|
data = build_multipart("people" => [{"submit-name" => "Larry", "files" => "contents"}])
|
108
108
|
data.should be_nil
|
109
109
|
end
|
data/spec/rack/test_spec.rb
CHANGED
@@ -146,12 +146,12 @@ describe Rack::Test::Session do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
context "when input is given" do
|
149
|
-
it "
|
149
|
+
it "sends the input" do
|
150
150
|
request "/", :method => "POST", :input => "foo"
|
151
151
|
last_request.env["rack.input"].read.should == "foo"
|
152
152
|
end
|
153
153
|
|
154
|
-
it "
|
154
|
+
it "does not send a multipart request" do
|
155
155
|
request "/", :method => "POST", :input => "foo"
|
156
156
|
last_request.env["CONTENT_TYPE"].should_not == "application/x-www-form-urlencoded"
|
157
157
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
require "
|
2
|
+
require "bundler/setup"
|
3
3
|
|
4
|
-
|
4
|
+
require "rack"
|
5
|
+
require "rspec"
|
6
|
+
|
7
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
5
8
|
|
6
9
|
require "rack/test"
|
7
10
|
require File.dirname(__FILE__) + "/fixtures/fake_app"
|
8
11
|
|
9
|
-
|
12
|
+
Rspec.configure do |config|
|
13
|
+
config.mock_with :rspec
|
10
14
|
config.include Rack::Test::Methods
|
11
15
|
|
12
16
|
def app
|
@@ -18,7 +22,7 @@ Spec::Runner.configure do |config|
|
|
18
22
|
|
19
23
|
end
|
20
24
|
|
21
|
-
|
25
|
+
shared_examples_for "any #verb methods" do
|
22
26
|
it "requests the URL using VERB" do
|
23
27
|
send(verb, "/")
|
24
28
|
|
@@ -42,6 +46,16 @@ describe "any #verb methods", :shared => true do
|
|
42
46
|
yielded.should be_true
|
43
47
|
end
|
44
48
|
|
49
|
+
it "sets the HTTP_HOST header with port" do
|
50
|
+
send(verb, "http://example.org:8080/uri")
|
51
|
+
last_request.env["HTTP_HOST"].should == "example.org:8080"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sets the HTTP_HOST header without port" do
|
55
|
+
send(verb, "/uri")
|
56
|
+
last_request.env["HTTP_HOST"].should == "example.org"
|
57
|
+
end
|
58
|
+
|
45
59
|
context "for a XHR" do
|
46
60
|
it "sends XMLHttpRequest for the X-Requested-With header" do
|
47
61
|
send(verb, "/", {}, { :xhr => true })
|
@@ -0,0 +1,11 @@
|
|
1
|
+
RSpec::Matchers.define :be_challenge do
|
2
|
+
match do |actual_response|
|
3
|
+
actual_response.status == 401 &&
|
4
|
+
actual_response['WWW-Authenticate'] =~ /^Digest / &&
|
5
|
+
actual_response.body.empty?
|
6
|
+
end
|
7
|
+
|
8
|
+
description do
|
9
|
+
"a HTTP Digest challenge response"
|
10
|
+
end
|
11
|
+
end
|
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:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 5
|
10
|
+
version: 0.5.5
|
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: 2010-
|
18
|
+
date: 2010-09-22 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,8 @@ extra_rdoc_files:
|
|
49
49
|
files:
|
50
50
|
- .document
|
51
51
|
- .gitignore
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
52
54
|
- History.txt
|
53
55
|
- MIT-LICENSE.txt
|
54
56
|
- README.rdoc
|
@@ -71,8 +73,10 @@ files:
|
|
71
73
|
- spec/rack/test/multipart_spec.rb
|
72
74
|
- spec/rack/test/utils_spec.rb
|
73
75
|
- spec/rack/test_spec.rb
|
74
|
-
- spec/spec.opts
|
75
76
|
- spec/spec_helper.rb
|
77
|
+
- spec/support/core_ext/string.rb
|
78
|
+
- spec/support/matchers/body.rb
|
79
|
+
- spec/support/matchers/challenge.rb
|
76
80
|
has_rdoc: true
|
77
81
|
homepage: http://github.com/brynary/rack-test
|
78
82
|
licenses: []
|
@@ -115,3 +119,6 @@ test_files:
|
|
115
119
|
- spec/rack/test/utils_spec.rb
|
116
120
|
- spec/rack/test_spec.rb
|
117
121
|
- spec/spec_helper.rb
|
122
|
+
- spec/support/core_ext/string.rb
|
123
|
+
- spec/support/matchers/body.rb
|
124
|
+
- spec/support/matchers/challenge.rb
|
data/spec/spec.opts
DELETED