rack-test 0.6.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.md +243 -0
- data/README.md +148 -0
- data/lib/rack/mock_session.rb +6 -9
- data/lib/rack/test/cookie_jar.rb +39 -27
- data/lib/rack/test/methods.rb +22 -22
- data/lib/rack/test/mock_digest_request.rb +1 -5
- data/lib/rack/test/uploaded_file.rb +51 -19
- data/lib/rack/test/utils.rb +37 -43
- data/lib/rack/test/version.rb +5 -0
- data/lib/rack/test.rb +94 -85
- metadata +139 -60
- data/.document +0 -4
- data/.gitignore +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -41
- data/History.txt +0 -179
- data/README.rdoc +0 -85
- data/Rakefile +0 -33
- data/Thorfile +0 -114
- data/rack-test.gemspec +0 -77
- data/spec/fixtures/bar.txt +0 -1
- data/spec/fixtures/config.ru +0 -3
- data/spec/fixtures/fake_app.rb +0 -143
- data/spec/fixtures/foo.txt +0 -1
- data/spec/rack/test/cookie_spec.rb +0 -219
- data/spec/rack/test/digest_auth_spec.rb +0 -46
- data/spec/rack/test/multipart_spec.rb +0 -145
- data/spec/rack/test/uploaded_file_spec.rb +0 -24
- data/spec/rack/test/utils_spec.rb +0 -193
- data/spec/rack/test_spec.rb +0 -550
- data/spec/spec_helper.rb +0 -69
- data/spec/support/matchers/body.rb +0 -9
- data/spec/support/matchers/challenge.rb +0 -11
data/.document
DELETED
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
codeclimate-test-reporter (0.3.0)
|
5
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
6
|
-
diff-lcs (1.2.3)
|
7
|
-
docile (1.1.3)
|
8
|
-
multi_json (1.9.0)
|
9
|
-
rack (1.5.2)
|
10
|
-
rack-protection (1.5.0)
|
11
|
-
rack
|
12
|
-
rake (10.0.4)
|
13
|
-
rspec (2.13.0)
|
14
|
-
rspec-core (~> 2.13.0)
|
15
|
-
rspec-expectations (~> 2.13.0)
|
16
|
-
rspec-mocks (~> 2.13.0)
|
17
|
-
rspec-core (2.13.1)
|
18
|
-
rspec-expectations (2.13.0)
|
19
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
-
rspec-mocks (2.13.1)
|
21
|
-
simplecov (0.8.2)
|
22
|
-
docile (~> 1.1.0)
|
23
|
-
multi_json
|
24
|
-
simplecov-html (~> 0.8.0)
|
25
|
-
simplecov-html (0.8.0)
|
26
|
-
sinatra (1.4.2)
|
27
|
-
rack (~> 1.5, >= 1.5.2)
|
28
|
-
rack-protection (~> 1.4)
|
29
|
-
tilt (~> 1.3, >= 1.3.4)
|
30
|
-
tilt (1.3.7)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
java
|
34
|
-
ruby
|
35
|
-
|
36
|
-
DEPENDENCIES
|
37
|
-
codeclimate-test-reporter
|
38
|
-
rack
|
39
|
-
rake
|
40
|
-
rspec
|
41
|
-
sinatra
|
data/History.txt
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
== 0.6.3 / 2015-01-09
|
2
|
-
|
3
|
-
* Minor enhancements
|
4
|
-
|
5
|
-
* Expose an env helper for persistently configuring the env as needed
|
6
|
-
(Darío Javier Cravero #80)
|
7
|
-
* Expose the tempfile of UploadedFile (Sytse Sijbrandij #67)
|
8
|
-
|
9
|
-
* Bug fixes
|
10
|
-
|
11
|
-
* Improve support for arrays of hashes in multipart forms (Murray Steele #69)
|
12
|
-
* Improve test for query strings (Paul Grayson #66)
|
13
|
-
|
14
|
-
== 0.6.2 / 2012-09-27
|
15
|
-
|
16
|
-
* Minor enhancements
|
17
|
-
|
18
|
-
* Support HTTP PATCH method (Marjan Krekoten' #33)
|
19
|
-
* Preserve the exact query string when possible (Paul Grayson #63)
|
20
|
-
* Add a #delete method to CookieJar (Paul Grayson #63)
|
21
|
-
|
22
|
-
* Bug fixes
|
23
|
-
|
24
|
-
* Fix HTTP Digest authentication when the URI has query params
|
25
|
-
* Don't append default ports to HTTP_HOST (David Lee #57)
|
26
|
-
|
27
|
-
== 0.6.1 / 2011-07-27
|
28
|
-
|
29
|
-
* Bug fixes
|
30
|
-
|
31
|
-
* Fix support for params with arrays in multipart forms (Joel Chippindale)
|
32
|
-
* Add respond_to? to Rack::Test::UploadedFile to match method_missing (Josh Nichols)
|
33
|
-
* Set the Referer header on requests issued by follow_redirect! (Ryan Bigg)
|
34
|
-
|
35
|
-
== 0.6.0 / 2011-05-03
|
36
|
-
|
37
|
-
* Bug fixes
|
38
|
-
|
39
|
-
* Add support for HTTP OPTIONS verb (Paolo "Nusco" Perrotta)
|
40
|
-
* Call #finish on MockResponses if it's available (Aaron Patterson)
|
41
|
-
* Allow HTTP_HOST to be set via #header (Geoff Buesing)
|
42
|
-
|
43
|
-
== 0.5.7 / 2011-01-01
|
44
|
-
|
45
|
-
* Bug fixes
|
46
|
-
|
47
|
-
* If no URI is present, include all cookies (Pratik Naik)
|
48
|
-
|
49
|
-
== 0.5.6 / 2010-09-25
|
50
|
-
|
51
|
-
* Bug fixes
|
52
|
-
|
53
|
-
* Use parse_nested_query for parsing URI like Rack does (Eugene Bolshakov)
|
54
|
-
* Don't depend on ActiveSupport extension to String (Bryan Helmkamp)
|
55
|
-
* Do not overwrite HTTP_HOST if it is set (Krekoten' Marjan)
|
56
|
-
|
57
|
-
== 0.5.5 / 2010-09-22
|
58
|
-
|
59
|
-
* Bug fixes
|
60
|
-
|
61
|
-
* Fix encoding of file uploads on Ruby 1.9 (Alan Kennedy)
|
62
|
-
* Set env["HTTP_HOST"] when making requests (Istvan Hoka)
|
63
|
-
|
64
|
-
== 0.5.4 / 2010-05-26
|
65
|
-
|
66
|
-
* Bug fixes
|
67
|
-
|
68
|
-
* Don't stomp on Content-Type's supplied via #header (Bryan Helmkamp)
|
69
|
-
* Fixed build_multipart to allow for arrays of files (Louis Rose)
|
70
|
-
* Don't raise an error if raw cookies contain a blank line (John Reilly)
|
71
|
-
* Handle parameter names with brackets properly (Tanner Donovan)
|
72
|
-
|
73
|
-
== 0.5.3 / 2009-11-27
|
74
|
-
|
75
|
-
* Bug fixes
|
76
|
-
|
77
|
-
* Fix cookie matching for subdomains (Marcin Kulik)
|
78
|
-
|
79
|
-
== 0.5.2 / 2009-11-13
|
80
|
-
|
81
|
-
* Bug fixes
|
82
|
-
|
83
|
-
* Call close on response body after iteration, not before (Simon Rozet)
|
84
|
-
* Add missing require for time in cookie_jar.rb (Jerry West)
|
85
|
-
|
86
|
-
== 0.5.1 / 2009-10-27
|
87
|
-
|
88
|
-
* Bug fixes
|
89
|
-
|
90
|
-
* Escape cookie values (John Pignata)
|
91
|
-
* Close the response body after each request, as per the Rack spec (Elomar França)
|
92
|
-
|
93
|
-
== 0.5.0 / 2009-09-19
|
94
|
-
|
95
|
-
* Bug fixes
|
96
|
-
|
97
|
-
* Set HTTP_X_REQUESTED_WITH in the Rack env when a request is made with :xhr => true (Ben Sales)
|
98
|
-
* Set headers in the Rack env in HTTP_USER_AGENT form
|
99
|
-
* Rack::Test now generates no Ruby warnings
|
100
|
-
|
101
|
-
== 0.4.2 / 2009-09-01
|
102
|
-
|
103
|
-
* Minor enhancements
|
104
|
-
|
105
|
-
* Merge in rack/master's build_multipart method which covers additional cases
|
106
|
-
* Accept raw :params string input and merge it with the query string
|
107
|
-
* Stringify and upcase request method (e.g. :post => "POST") (Josh Peek)
|
108
|
-
|
109
|
-
* Bug fixes
|
110
|
-
|
111
|
-
* Properly convert hashes with nil values (e.g. :foo => nil becomes simply "foo", not "foo=")
|
112
|
-
* Prepend a slash to the URI path if it doesn't start with one (Josh Peek)
|
113
|
-
* Requiring Rack-Test never modifies the Ruby load path anymore (Josh Peek)
|
114
|
-
* Fixed using multiple cookies in a string on Ruby 1.8 (Tuomas Kareinen and Hermanni Hyytiälä)
|
115
|
-
|
116
|
-
== 0.4.1 / 2009-08-06
|
117
|
-
|
118
|
-
* Minor enhancements
|
119
|
-
|
120
|
-
* Support initializing a Rack::Test::Session with an app in addition to
|
121
|
-
a Rack::MockSession
|
122
|
-
* Allow CONTENT_TYPE to be specified in the env and not overwritten when
|
123
|
-
sending a POST or PUT
|
124
|
-
|
125
|
-
== 0.4.0 / 2009-06-25
|
126
|
-
|
127
|
-
* Minor enhancements
|
128
|
-
|
129
|
-
* Expose hook for building Rack::MockSessions for frameworks that need
|
130
|
-
to configure them before use
|
131
|
-
* Support passing in arrays of raw cookies in addition to a newline
|
132
|
-
separated string
|
133
|
-
* Support after_request callbacks in MockSession for things like running
|
134
|
-
background jobs
|
135
|
-
* Allow multiple named sessions using with_session
|
136
|
-
* Initialize Rack::Test::Sessions with Rack::MockSessions instead of apps.
|
137
|
-
This change should help integration with other Ruby web frameworks
|
138
|
-
(like Merb).
|
139
|
-
* Support sending bodies for PUT requests (Larry Diehl)
|
140
|
-
|
141
|
-
== 0.3.0 / 2009-05-17
|
142
|
-
|
143
|
-
* Major enhancements
|
144
|
-
|
145
|
-
* Ruby 1.9 compatible (Simon Rozet, Michael Fellinger)
|
146
|
-
|
147
|
-
* Minor enhancements
|
148
|
-
|
149
|
-
* Add CookieJar#[] and CookieJar#[]= methods
|
150
|
-
* Make the default host configurable
|
151
|
-
* Use Rack::Lint and fix errors (Simon Rozet)
|
152
|
-
* Extract Rack::MockSession from Rack::Test::Session to handle tracking
|
153
|
-
the last request and response and the cookie jar
|
154
|
-
* Add #set_cookie and #clear_cookies methods
|
155
|
-
* Rename #authorize to #basic_authorize (#authorize remains as an alias)
|
156
|
-
(Simon Rozet)
|
157
|
-
|
158
|
-
== 0.2.0 / 2009-04-26
|
159
|
-
|
160
|
-
Because #last_response is now a MockResponse instead of a Rack::Response,
|
161
|
-
#last_response.body now returns a string instead of an array.
|
162
|
-
|
163
|
-
* Major enhancements
|
164
|
-
|
165
|
-
* Support multipart requests via the UploadedFile class (thanks, Rails)
|
166
|
-
|
167
|
-
* Minor enhancements
|
168
|
-
|
169
|
-
* Updated for Rack 1.0
|
170
|
-
* Don't require rubygems (See http://gist.github.com/54177)
|
171
|
-
* Support HTTP Digest authentication with the #digest_authorize method
|
172
|
-
* #last_response returns a MockResponse instead of a Response
|
173
|
-
(Michael Fellinger)
|
174
|
-
|
175
|
-
== 0.1.0 / 2009-03-02
|
176
|
-
|
177
|
-
* 1 major enhancement
|
178
|
-
|
179
|
-
* Birthday!
|
data/README.rdoc
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
= Rack::Test {<img src="https://codeclimate.com/github/brynary/rack-test.png" />}[https://codeclimate.com/github/brynary/rack-test] {<img src="https://codeclimate.com/github/brynary/rack-test/coverage.png" />}[https://codeclimate.com/github/brynary/rack-test]
|
2
|
-
|
3
|
-
- Code: http://github.com/brynary/rack-test
|
4
|
-
|
5
|
-
== Description
|
6
|
-
|
7
|
-
Rack::Test is a small, simple testing API for Rack apps. It can be used on its
|
8
|
-
own or as a reusable starting point for Web frameworks and testing libraries
|
9
|
-
to build on. Most of its initial functionality is an extraction of Merb 1.0's
|
10
|
-
request helpers feature.
|
11
|
-
|
12
|
-
== Features
|
13
|
-
|
14
|
-
* Maintains a cookie jar across requests
|
15
|
-
* Easily follow redirects when desired
|
16
|
-
* Set request headers to be used by all subsequent requests
|
17
|
-
* Small footprint. Approximately 200 LOC
|
18
|
-
|
19
|
-
== Examples
|
20
|
-
|
21
|
-
require "rack/test"
|
22
|
-
|
23
|
-
class HomepageTest < Test::Unit::TestCase
|
24
|
-
include Rack::Test::Methods
|
25
|
-
|
26
|
-
def app
|
27
|
-
MyApp.new
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_redirect_logged_in_users_to_dashboard
|
31
|
-
authorize "bryan", "secret"
|
32
|
-
get "/"
|
33
|
-
follow_redirect!
|
34
|
-
|
35
|
-
assert_equal "http://example.org/redirected", last_request.url
|
36
|
-
assert last_response.ok?
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
If you want to test one app in isolation, you just return that app as shown above. But if you want to test the entire app stack, including middlewares, cascades etc. you need to parse the app defined in config.ru.
|
43
|
-
|
44
|
-
OUTER_APP = Rack::Builder.parse_file('config.ru').first
|
45
|
-
|
46
|
-
class TestApp < Test::Unit::TestCase
|
47
|
-
include Rack::Test::Methods
|
48
|
-
|
49
|
-
def app
|
50
|
-
OUTER_APP
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_root
|
54
|
-
get '/'
|
55
|
-
assert last_response.ok?
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
== Install
|
61
|
-
|
62
|
-
To install the latest release as a gem:
|
63
|
-
|
64
|
-
sudo gem install rack-test
|
65
|
-
|
66
|
-
Or via Bundler:
|
67
|
-
|
68
|
-
gem "rack-test", require: "rack/test"
|
69
|
-
|
70
|
-
== Authors
|
71
|
-
|
72
|
-
- Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
|
73
|
-
- Contributions from Simon Rozet, Pat Nakajima and others
|
74
|
-
- Much of the original code was extracted from Merb 1.0's request helper
|
75
|
-
|
76
|
-
== License
|
77
|
-
|
78
|
-
Copyright (c) 2008-2009 Bryan Helmkamp, Engine Yard Inc.
|
79
|
-
See MIT-LICENSE.txt in this directory.
|
80
|
-
|
81
|
-
== Releasing
|
82
|
-
|
83
|
-
* Ensure History.txt is up-to-date
|
84
|
-
* Bump VERSION in lib/rack/test.rb
|
85
|
-
* thor :release
|
data/Rakefile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
|
3
|
-
|
4
|
-
require 'rspec/core'
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new do |t|
|
8
|
-
t.pattern = "./**/*_spec.rb"
|
9
|
-
t.ruby_opts = "-w"
|
10
|
-
end
|
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
|
-
|
23
|
-
desc "Generate RDoc"
|
24
|
-
task :docs do
|
25
|
-
FileUtils.rm_rf("doc")
|
26
|
-
require "rack/test"
|
27
|
-
system "hanna --title 'Rack::Test #{Rack::Test::VERSION} API Documentation'"
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Removes trailing whitespace'
|
31
|
-
task :whitespace do
|
32
|
-
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
33
|
-
end
|
data/Thorfile
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
module GemHelpers
|
2
|
-
|
3
|
-
def generate_gemspec
|
4
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
|
5
|
-
require "rack/test"
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "rack-test"
|
9
|
-
s.version = Rack::Test::VERSION
|
10
|
-
s.author = "Bryan Helmkamp"
|
11
|
-
s.email = "bryan@brynary.com"
|
12
|
-
s.homepage = "http://github.com/brynary/rack-test"
|
13
|
-
s.summary = "Simple testing API built on Rack"
|
14
|
-
s.description = <<-EOS.strip
|
15
|
-
Rack::Test is a small, simple testing API for Rack apps. It can be used on its
|
16
|
-
own or as a reusable starting point for Web frameworks and testing libraries
|
17
|
-
to build on. Most of its initial functionality is an extraction of Merb 1.0's
|
18
|
-
request helpers feature.
|
19
|
-
EOS
|
20
|
-
s.rubyforge_project = "rack-test"
|
21
|
-
|
22
|
-
require "git"
|
23
|
-
repo = Git.open(".")
|
24
|
-
|
25
|
-
s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
|
26
|
-
s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
|
27
|
-
|
28
|
-
s.has_rdoc = true
|
29
|
-
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt]
|
30
|
-
|
31
|
-
s.add_dependency "rack", ">= 1.0"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def normalize_files(array)
|
36
|
-
# only keep files, no directories, and sort
|
37
|
-
array.select do |path|
|
38
|
-
File.file?(path)
|
39
|
-
end.sort
|
40
|
-
end
|
41
|
-
|
42
|
-
# Adds extra space when outputting an array. This helps create better version
|
43
|
-
# control diffs, because otherwise it is all on the same line.
|
44
|
-
def prettyify_array(gemspec_ruby, array_name)
|
45
|
-
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
46
|
-
leadin, files = match[0..-2].split("[")
|
47
|
-
leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def read_gemspec
|
52
|
-
@read_gemspec ||= eval(File.read("rack-test.gemspec"))
|
53
|
-
end
|
54
|
-
|
55
|
-
def sh(command)
|
56
|
-
puts command
|
57
|
-
system command
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class Default < Thor
|
62
|
-
include GemHelpers
|
63
|
-
|
64
|
-
desc "gemspec", "Regenerate rack-test.gemspec"
|
65
|
-
def gemspec
|
66
|
-
File.open("rack-test.gemspec", "w") do |file|
|
67
|
-
gemspec_ruby = generate_gemspec.to_ruby
|
68
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :files)
|
69
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
|
70
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
|
71
|
-
|
72
|
-
file.write gemspec_ruby
|
73
|
-
end
|
74
|
-
|
75
|
-
puts "Wrote gemspec to rack-test.gemspec"
|
76
|
-
read_gemspec.validate
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "build", "Build a rack-test gem"
|
80
|
-
def build
|
81
|
-
sh "gem build rack-test.gemspec"
|
82
|
-
FileUtils.mkdir_p "pkg"
|
83
|
-
FileUtils.mv read_gemspec.file_name, "pkg"
|
84
|
-
end
|
85
|
-
|
86
|
-
desc "install", "Install the latest built gem"
|
87
|
-
def install
|
88
|
-
sh "gem install --local pkg/#{read_gemspec.file_name}"
|
89
|
-
end
|
90
|
-
|
91
|
-
desc "release", "Release the current branch to GitHub and Gemcutter"
|
92
|
-
def release
|
93
|
-
gemspec
|
94
|
-
build
|
95
|
-
Release.new.tag
|
96
|
-
Release.new.gem
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class Release < Thor
|
101
|
-
include GemHelpers
|
102
|
-
|
103
|
-
desc "tag", "Tag the gem on the origin server"
|
104
|
-
def tag
|
105
|
-
release_tag = "v#{read_gemspec.version}"
|
106
|
-
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
|
107
|
-
sh "git push origin #{release_tag}"
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "gem", "Push the gem to Gemcutter"
|
111
|
-
def gem
|
112
|
-
sh "gem push pkg/#{read_gemspec.file_name}"
|
113
|
-
end
|
114
|
-
end
|