joebadmo-rack-test 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/.document ADDED
@@ -0,0 +1,4 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ History.txt
4
+ MIT-LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg
2
+ doc
3
+ coverage
4
+ VERSION
5
+ *.rbc
6
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'rspec'
4
+ gem "rack"
5
+ gem "sinatra"
6
+ gem 'rake'
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ rack (1.4.0)
6
+ rack-protection (1.2.0)
7
+ rack
8
+ rake (0.9.2)
9
+ rspec (2.8.0)
10
+ rspec-core (~> 2.8.0)
11
+ rspec-expectations (~> 2.8.0)
12
+ rspec-mocks (~> 2.8.0)
13
+ rspec-core (2.8.0)
14
+ rspec-expectations (2.8.0)
15
+ diff-lcs (~> 1.1.2)
16
+ rspec-mocks (2.8.0)
17
+ sinatra (1.3.2)
18
+ rack (~> 1.3, >= 1.3.6)
19
+ rack-protection (~> 1.2)
20
+ tilt (~> 1.3, >= 1.3.3)
21
+ tilt (1.3.3)
22
+
23
+ PLATFORMS
24
+ java
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ rack
29
+ rake
30
+ rspec
31
+ sinatra
data/History.txt ADDED
@@ -0,0 +1,163 @@
1
+ == Git
2
+
3
+ * Minor enhancements
4
+
5
+ * Support HTTP PATCH method (Marjan Krekoten' #33)
6
+
7
+ * Bug fixes
8
+
9
+ * Fix HTTP Digest authentication when the URI has query params
10
+
11
+ == 0.6.1 / 2011-07-27
12
+
13
+ * Bug fixes
14
+
15
+ * Fix support for params with arrays in multipart forms (Joel Chippindale)
16
+ * Add respond_to? to Rack::Test::UploadedFile to match method_missing (Josh Nichols)
17
+ * Set the Referer header on requests issued by follow_redirect! (Ryan Bigg)
18
+
19
+ == 0.6.0 / 2011-05-03
20
+
21
+ * Bug fixes
22
+
23
+ * Add support for HTTP OPTIONS verb (Paolo "Nusco" Perrotta)
24
+ * Call #finish on MockResponses if it's available (Aaron Patterson)
25
+ * Allow HTTP_HOST to be set via #header (Geoff Buesing)
26
+
27
+ == 0.5.7 / 2011-01-01
28
+
29
+ * Bug fixes
30
+
31
+ * If no URI is present, include all cookies (Pratik Naik)
32
+
33
+ == 0.5.6 / 2010-09-25
34
+
35
+ * Bug fixes
36
+
37
+ * Use parse_nested_query for parsing URI like Rack does (Eugene Bolshakov)
38
+ * Don't depend on ActiveSupport extension to String (Bryan Helmkamp)
39
+ * Do not overwrite HTTP_HOST if it is set (Krekoten' Marjan)
40
+
41
+ == 0.5.5 / 2010-09-22
42
+
43
+ * Bug fixes
44
+
45
+ * Fix encoding of file uploads on Ruby 1.9 (Alan Kennedy)
46
+ * Set env["HTTP_HOST"] when making requests (Istvan Hoka)
47
+
48
+ == 0.5.4 / 2010-05-26
49
+
50
+ * Bug fixes
51
+
52
+ * Don't stomp on Content-Type's supplied via #header (Bryan Helmkamp)
53
+ * Fixed build_multipart to allow for arrays of files (Louis Rose)
54
+ * Don't raise an error if raw cookies contain a blank line (John Reilly)
55
+ * Handle parameter names with brackets properly (Tanner Donovan)
56
+
57
+ == 0.5.3 / 2009-11-27
58
+
59
+ * Bug fixes
60
+
61
+ * Fix cookie matching for subdomains (Marcin Kulik)
62
+
63
+ == 0.5.2 / 2009-11-13
64
+
65
+ * Bug fixes
66
+
67
+ * Call close on response body after iteration, not before (Simon Rozet)
68
+ * Add missing require for time in cookie_jar.rb (Jerry West)
69
+
70
+ == 0.5.1 / 2009-10-27
71
+
72
+ * Bug fixes
73
+
74
+ * Escape cookie values (John Pignata)
75
+ * Close the response body after each request, as per the Rack spec (Elomar França)
76
+
77
+ == 0.5.0 / 2009-09-19
78
+
79
+ * Bug fixes
80
+
81
+ * Set HTTP_X_REQUESTED_WITH in the Rack env when a request is made with :xhr => true (Ben Sales)
82
+ * Set headers in the Rack env in HTTP_USER_AGENT form
83
+ * Rack::Test now generates no Ruby warnings
84
+
85
+ == 0.4.2 / 2009-09-01
86
+
87
+ * Minor enhancements
88
+
89
+ * Merge in rack/master's build_multipart method which covers additional cases
90
+ * Accept raw :params string input and merge it with the query string
91
+ * Stringify and upcase request method (e.g. :post => "POST") (Josh Peek)
92
+
93
+ * Bug fixes
94
+
95
+ * Properly convert hashes with nil values (e.g. :foo => nil becomes simply "foo", not "foo=")
96
+ * Prepend a slash to the URI path if it doesn't start with one (Josh Peek)
97
+ * Requiring Rack-Test never modifies the Ruby load path anymore (Josh Peek)
98
+ * Fixed using multiple cookies in a string on Ruby 1.8 (Tuomas Kareinen and Hermanni Hyytiälä)
99
+
100
+ == 0.4.1 / 2009-08-06
101
+
102
+ * Minor enhancements
103
+
104
+ * Support initializing a Rack::Test::Session with an app in addition to
105
+ a Rack::MockSession
106
+ * Allow CONTENT_TYPE to be specified in the env and not overwritten when
107
+ sending a POST or PUT
108
+
109
+ == 0.4.0 / 2009-06-25
110
+
111
+ * Minor enhancements
112
+
113
+ * Expose hook for building Rack::MockSessions for frameworks that need
114
+ to configure them before use
115
+ * Support passing in arrays of raw cookies in addition to a newline
116
+ separated string
117
+ * Support after_request callbacks in MockSession for things like running
118
+ background jobs
119
+ * Allow multiple named sessions using with_session
120
+ * Initialize Rack::Test::Sessions with Rack::MockSessions instead of apps.
121
+ This change should help integration with other Ruby web frameworks
122
+ (like Merb).
123
+ * Support sending bodies for PUT requests (Larry Diehl)
124
+
125
+ == 0.3.0 / 2009-05-17
126
+
127
+ * Major enhancements
128
+
129
+ * Ruby 1.9 compatible (Simon Rozet, Michael Fellinger)
130
+
131
+ * Minor enhancements
132
+
133
+ * Add CookieJar#[] and CookieJar#[]= methods
134
+ * Make the default host configurable
135
+ * Use Rack::Lint and fix errors (Simon Rozet)
136
+ * Extract Rack::MockSession from Rack::Test::Session to handle tracking
137
+ the last request and response and the cookie jar
138
+ * Add #set_cookie and #clear_cookies methods
139
+ * Rename #authorize to #basic_authorize (#authorize remains as an alias)
140
+ (Simon Rozet)
141
+
142
+ == 0.2.0 / 2009-04-26
143
+
144
+ Because #last_response is now a MockResponse instead of a Rack::Response,
145
+ #last_response.body now returns a string instead of an array.
146
+
147
+ * Major enhancements
148
+
149
+ * Support multipart requests via the UploadedFile class (thanks, Rails)
150
+
151
+ * Minor enhancements
152
+
153
+ * Updated for Rack 1.0
154
+ * Don't require rubygems (See http://gist.github.com/54177)
155
+ * Support HTTP Digest authentication with the #digest_authorize method
156
+ * #last_response returns a MockResponse instead of a Response
157
+ (Michael Fellinger)
158
+
159
+ == 0.1.0 / 2009-03-02
160
+
161
+ * 1 major enhancement
162
+
163
+ * Birthday!
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008-2009 Bryan Helmkamp, Engine Yard Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,60 @@
1
+ = Rack::Test {<img src="https://codeclimate.com/badge.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
+ == Example
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
+ == Install
42
+
43
+ To install the latest release as a gem:
44
+
45
+ sudo gem install rack-test
46
+
47
+ Or via Bundler:
48
+
49
+ gem "rack-test", require: "rack/test"
50
+
51
+ == Authors
52
+
53
+ - Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
54
+ - Contributions from Simon Rozet and Pat Nakajima
55
+ - Much of the original code was extracted from Merb 1.0's request helper
56
+
57
+ == License
58
+
59
+ Copyright (c) 2008-2009 Bryan Helmkamp, Engine Yard Inc.
60
+ See MIT-LICENSE.txt in this directory.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
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 ADDED
@@ -0,0 +1,114 @@
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