manveru-innate 2009.03.24 → 2009.04
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +354 -0
- data/MANIFEST +34 -22
- data/README.md +2 -10
- data/Rakefile +30 -247
- data/example/app/retro_games.rb +8 -8
- data/example/app/todo/layout/{default.erb → default.xhtml} +1 -1
- data/example/app/todo/view/{index.erb → index.xhtml} +11 -11
- data/example/app/whywiki_erb/start.rb +2 -1
- data/example/app/whywiki_erb/view/{edit.html.erb → edit.erb} +0 -0
- data/example/app/whywiki_erb/view/{index.html.erb → index.erb} +0 -0
- data/example/howto_spec.rb +1 -1
- data/example/provides.rb +9 -6
- data/example/session.rb +3 -3
- data/innate.gemspec +23 -127
- data/lib/innate/action.rb +24 -13
- data/lib/innate/adapter.rb +5 -27
- data/lib/innate/cache/file_based.rb +2 -0
- data/lib/innate/cache.rb +1 -1
- data/lib/innate/current.rb +5 -5
- data/lib/innate/dynamap.rb +5 -0
- data/lib/innate/helper/cgi.rb +32 -19
- data/lib/innate/helper/link.rb +2 -2
- data/lib/innate/helper/redirect.rb +1 -1
- data/lib/innate/helper/render.rb +87 -0
- data/lib/innate/helper/send_file.rb +9 -1
- data/lib/innate/helper.rb +20 -29
- data/lib/innate/log/hub.rb +1 -1
- data/lib/innate/middleware_compiler.rb +1 -15
- data/lib/innate/mock.rb +2 -3
- data/lib/innate/node.rb +85 -55
- data/lib/innate/options/dsl.rb +1 -1
- data/lib/innate/options.rb +1 -1
- data/lib/innate/request.rb +3 -76
- data/lib/innate/response.rb +1 -8
- data/lib/innate/session.rb +2 -3
- data/lib/innate/spec.rb +6 -50
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view/erb.rb +1 -5
- data/lib/innate/view/etanni.rb +36 -0
- data/lib/innate/view/none.rb +1 -1
- data/lib/innate/view.rb +14 -16
- data/lib/innate.rb +27 -53
- data/spec/example/app/retro_games.rb +30 -0
- data/spec/example/provides.rb +16 -0
- data/spec/example/session.rb +8 -14
- data/spec/innate/action/layout/file_layout.xhtml +1 -0
- data/spec/innate/action/layout.rb +1 -1
- data/spec/innate/helper/aspect.rb +6 -6
- data/spec/innate/helper/flash.rb +28 -47
- data/spec/innate/helper/link.rb +8 -0
- data/spec/innate/helper/redirect.rb +58 -43
- data/spec/innate/helper/render.rb +133 -0
- data/spec/innate/helper/view/aspect_hello.xhtml +1 -0
- data/spec/innate/helper/view/locals.xhtml +1 -0
- data/spec/innate/helper/view/loop.xhtml +4 -0
- data/spec/innate/helper/view/num.xhtml +1 -0
- data/spec/innate/helper/view/partial.xhtml +1 -0
- data/spec/innate/helper/view/recursive.xhtml +7 -0
- data/spec/innate/node/node.rb +5 -13
- data/spec/innate/node/view/another_layout/{another_layout.erb → another_layout.xhtml} +1 -1
- data/spec/innate/node/view/{bar.erb → bar.xhtml} +0 -0
- data/spec/innate/node/view/foo.html.xhtml +1 -0
- data/spec/innate/node/view/{only_view.erb → only_view.xhtml} +0 -0
- data/spec/innate/node/view/with_layout.xhtml +1 -0
- data/spec/innate/provides/list.html.xhtml +1 -0
- data/spec/innate/provides/list.txt.xhtml +1 -0
- data/spec/innate/provides.rb +2 -2
- data/spec/innate/request.rb +0 -9
- data/spec/innate/session.rb +14 -15
- data/spec/innate/state/fiber.rb +8 -7
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/gem.rake +22 -0
- data/tasks/gem_installer.rake +76 -0
- data/tasks/grancher.rake +12 -0
- data/tasks/install_dependencies.rake +4 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/rcov.rake +19 -0
- data/tasks/release.rake +51 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +28 -0
- metadata +41 -38
- data/lib/innate/core_compatibility/basic_object.rb +0 -10
- data/lib/innate/core_compatibility/string.rb +0 -3
- data/lib/innate/helper/partial.rb +0 -93
- data/spec/innate/action/layout/file_layout.erb +0 -1
- data/spec/innate/helper/partial.rb +0 -101
- data/spec/innate/helper/view/aspect_hello.erb +0 -1
- data/spec/innate/helper/view/locals.erb +0 -1
- data/spec/innate/helper/view/loop.erb +0 -4
- data/spec/innate/helper/view/num.erb +0 -1
- data/spec/innate/helper/view/partial.erb +0 -1
- data/spec/innate/helper/view/recursive.erb +0 -8
- data/spec/innate/node/view/foo.html.erb +0 -1
- data/spec/innate/node/view/with_layout.erb +0 -1
- data/spec/innate/provides/list.html.erb +0 -1
- data/spec/innate/provides/list.txt.erb +0 -1
data/lib/innate.rb
CHANGED
@@ -3,11 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Name-space of Innate, just about everything goes in here.
|
5
5
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# * Logger::ColorFormatter
|
9
|
-
# * In 1.8, we define ::BasicObject
|
10
|
-
# * In 1.9, we define ::String#each
|
6
|
+
# The only exception is Logger::ColorFormatter.
|
11
7
|
#
|
12
8
|
module Innate
|
13
9
|
ROOT = File.expand_path(File.dirname(__FILE__))
|
@@ -30,10 +26,6 @@ module Innate
|
|
30
26
|
# 3rd party
|
31
27
|
require 'rack'
|
32
28
|
|
33
|
-
# innates ruby core patches
|
34
|
-
require 'innate/core_compatibility/string'
|
35
|
-
require 'innate/core_compatibility/basic_object'
|
36
|
-
|
37
29
|
# innate core
|
38
30
|
require 'innate/version'
|
39
31
|
require 'innate/traited'
|
@@ -97,7 +89,7 @@ module Innate
|
|
97
89
|
# Port for the server
|
98
90
|
# @option param :started [boolean] (false)
|
99
91
|
# Indicate that calls Innate::start will be ignored
|
100
|
-
# @option param :
|
92
|
+
# @option param :adapter [Symbol] (:webrick)
|
101
93
|
# Web server to run on
|
102
94
|
# @option param :setup [Array] ([Innate::Cache, Innate::Node])
|
103
95
|
# Will send ::setup to each element during Innate::start
|
@@ -113,14 +105,14 @@ module Innate
|
|
113
105
|
root = given_options.delete(:root)
|
114
106
|
file = given_options.delete(:file)
|
115
107
|
|
116
|
-
|
117
|
-
|
118
|
-
Innate.options.roots = [found_root]
|
119
|
-
end
|
108
|
+
found_root = go_figure_root(caller, :root => root, :file => file)
|
109
|
+
Innate.options.roots = [found_root] if found_root
|
120
110
|
|
111
|
+
# Convert some top-level option keys to the internal ones that we use.
|
121
112
|
PROXY_OPTIONS.each{|k,v| given_options[v] = given_options.delete(k) }
|
122
113
|
given_options.delete_if{|k,v| v.nil? }
|
123
114
|
|
115
|
+
# Merge the user's given options into our existing set, which contains defaults.
|
124
116
|
options.merge!(given_options)
|
125
117
|
|
126
118
|
setup_dependencies
|
@@ -179,47 +171,27 @@ module Innate
|
|
179
171
|
options[:middleware_compiler]::COMPILED[mode].compile!
|
180
172
|
end
|
181
173
|
|
182
|
-
# Innate can be started by:
|
174
|
+
# @example Innate can be started by:
|
183
175
|
#
|
184
176
|
# Innate.start :file => __FILE__
|
185
|
-
# Innate.start :root =>
|
177
|
+
# Innate.start :root => File.dirname(__FILE__)
|
186
178
|
#
|
187
|
-
#
|
188
|
-
#
|
179
|
+
# Either setting will surpress the warning that might show up on startup
|
180
|
+
# and tells you it couldn't find an explicit root.
|
189
181
|
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
def go_figure_root(
|
193
|
-
if
|
194
|
-
|
195
|
-
elsif
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
caller_lines(backtrace) do |file, line, method|
|
204
|
-
dir, file = File.split(File.expand_path(file))
|
205
|
-
return dir if file == "start.rb"
|
206
|
-
end
|
207
|
-
|
208
|
-
Log.warn("Couldn't find your application root, see Innate#go_figure_root")
|
209
|
-
|
210
|
-
return nil
|
211
|
-
end
|
212
|
-
|
213
|
-
# yields +file+, +line+, +method+
|
214
|
-
def caller_lines(backtrace)
|
215
|
-
backtrace.each do |line|
|
216
|
-
if line =~ /^(.*?):(\d+):in `(.*)'$/
|
217
|
-
file, line, method = $1, $2.to_i, $3
|
218
|
-
elsif line =~ /^(.*?):(\d+)$/
|
219
|
-
file, line, method = $1, $2.to_i, nil
|
220
|
-
end
|
221
|
-
|
222
|
-
yield(File.expand_path(file), line, method) if file and File.file?(file)
|
182
|
+
# In case these options are not passed we will try to figure out a file named
|
183
|
+
# `start.rb` in the process' working directory and assume it's a valid point.
|
184
|
+
def go_figure_root(backtrace, options)
|
185
|
+
if root = options[:root]
|
186
|
+
root
|
187
|
+
elsif file = options[:file]
|
188
|
+
File.dirname(file)
|
189
|
+
elsif File.file?('start.rb')
|
190
|
+
Dir.pwd
|
191
|
+
else
|
192
|
+
root = File.dirname(backtrace[0][/^(.*?):\d+/, 1])
|
193
|
+
Log.warn "No explicit root folder found, assuming it is #{root}"
|
194
|
+
root
|
223
195
|
end
|
224
196
|
end
|
225
197
|
end
|
@@ -283,13 +255,15 @@ module Innate
|
|
283
255
|
# @see Rack::MiddlewareCompiler
|
284
256
|
middleware :dev do |m|
|
285
257
|
m.apps(Rack::Lint, Rack::CommonLogger, Rack::ShowExceptions,
|
286
|
-
Rack::ShowStatus, Rack::ConditionalGet, Rack::
|
258
|
+
Rack::ShowStatus, Rack::ConditionalGet, Rack::ContentLength,
|
259
|
+
Rack::Head)
|
260
|
+
m.use(Rack::Reloader, 2)
|
287
261
|
m.innate
|
288
262
|
end
|
289
263
|
|
290
264
|
middleware :live do |m|
|
291
265
|
m.apps(Rack::CommonLogger, Rack::ShowStatus, Rack::ConditionalGet,
|
292
|
-
Rack::Head)
|
266
|
+
Rack::ContentLength, Rack::Head)
|
293
267
|
m.innate
|
294
268
|
end
|
295
269
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require 'example/app/retro_games'
|
3
|
+
|
4
|
+
describe 'Retro-games app' do
|
5
|
+
behaves_like :mock
|
6
|
+
|
7
|
+
it 'lists the first game' do
|
8
|
+
get '/'
|
9
|
+
last_response.should =~ /1 => Pacman/
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'has a form to add another game' do
|
13
|
+
get '/'
|
14
|
+
last_response.should =~ /<form/
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'allows you to add another game' do
|
18
|
+
post '/create', :name => 'Street Fighter II'
|
19
|
+
follow_redirect!
|
20
|
+
last_response.should =~ /0 => Street Fighter II/
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'allows you to vote for a game' do
|
24
|
+
get '/vote/Street+Fighter+II'
|
25
|
+
follow_redirect!
|
26
|
+
last_response.should =~ /1 => Street Fighter II/
|
27
|
+
end
|
28
|
+
|
29
|
+
FileUtils.rm_f('games.yaml')
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require 'example/provides'
|
3
|
+
|
4
|
+
describe 'examples/provide' do
|
5
|
+
behaves_like :mock
|
6
|
+
|
7
|
+
it 'provides YAML representation' do
|
8
|
+
get '/list.yaml'
|
9
|
+
last_response.body.should == ARTICLES.to_yaml
|
10
|
+
last_response['Content-Type'].should == 'text/yaml'
|
11
|
+
|
12
|
+
get '/list'
|
13
|
+
last_response.body.should == ''
|
14
|
+
last_response['Content-Type'].should == 'text/html'
|
15
|
+
end
|
16
|
+
end
|
data/spec/example/session.rb
CHANGED
@@ -2,27 +2,21 @@ require 'spec/helper'
|
|
2
2
|
require 'example/session'
|
3
3
|
|
4
4
|
describe 'example/session' do
|
5
|
-
behaves_like :
|
5
|
+
behaves_like :mock
|
6
6
|
|
7
7
|
it 'starts at 0' do
|
8
|
-
|
9
|
-
mock.get('/').should =~ /Value is: 0/
|
10
|
-
end
|
8
|
+
get('/').body.should =~ /Value is: 0/
|
11
9
|
end
|
12
10
|
|
13
11
|
it 'increments the counter' do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
mock.get('/increment').should =~ /Value is: 3/
|
18
|
-
end
|
12
|
+
get('/increment').body.should =~ /Value is: 1/
|
13
|
+
get('/increment').body.should =~ /Value is: 2/
|
14
|
+
get('/increment').body.should =~ /Value is: 3/
|
19
15
|
end
|
20
16
|
|
21
17
|
it 'decrements the counter' do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
mock.get('/decrement').should =~ /Value is: -3/
|
26
|
-
end
|
18
|
+
get('/decrement').body.should =~ /Value is: 2/
|
19
|
+
get('/decrement').body.should =~ /Value is: 1/
|
20
|
+
get('/decrement').body.should =~ /Value is: 0/
|
27
21
|
end
|
28
22
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>#{ @content }</p>
|
@@ -38,25 +38,25 @@ end
|
|
38
38
|
describe Innate::Helper::Aspect do
|
39
39
|
behaves_like :mock
|
40
40
|
|
41
|
-
|
41
|
+
it 'executes before aspect' do
|
42
42
|
$aspect_spec_before = 0
|
43
43
|
get('/with_before').body.should == '42'
|
44
44
|
$aspect_spec_before.should == 42
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
it 'executes after asepct' do
|
48
48
|
$aspect_spec_after = 0
|
49
49
|
get('/with_after').body.should == '2'
|
50
50
|
$aspect_spec_after.should == 42
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
it 'executes wrap aspects' do
|
54
54
|
$aspect_spec_wrap = 0
|
55
55
|
get('/with_wrap').body.should == '22'
|
56
56
|
$aspect_spec_wrap == 42
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
it 'calls before_all and after_all' do
|
60
60
|
$aspect_spec_before_all = $aspect_spec_after_all = 0
|
61
61
|
get('/all/before_first').body.should == '42'
|
62
62
|
$aspect_spec_before_all.should == 42
|
@@ -66,10 +66,10 @@ describe Innate::Helper::Aspect do
|
|
66
66
|
$aspect_spec_after_all.should == 80
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
it 'makes instance variables in blocks available to view/method' do
|
70
70
|
get('/with_instance_var').body.should == 'Hello World'
|
71
71
|
get('/all/with_instance_var_first').body.should == 'Hello World'
|
72
72
|
get('/all/with_instance_var_second').body.should == 'Hello to the World'
|
73
|
-
get('/without_method/aspect_hello').body.should == "Hello World
|
73
|
+
get('/without_method/aspect_hello').body.should == "Hello World!"
|
74
74
|
end
|
75
75
|
end
|
data/spec/innate/helper/flash.rb
CHANGED
@@ -57,81 +57,62 @@ class SpecFlashSub < SpecFlash
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe Innate::Helper::Flash do
|
60
|
-
behaves_like :
|
60
|
+
behaves_like :mock
|
61
61
|
|
62
62
|
should 'set and forget flash twice' do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
mock.get('/bye').body.should == 'Bye '
|
63
|
+
get('/welcome').body.should == 'Welcome manveru'
|
64
|
+
get('/bye').body.should == 'Bye manveru'
|
65
|
+
get('/bye').body.should == 'Bye'
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
67
|
+
get('/welcome').body.should == 'Welcome manveru'
|
68
|
+
get('/bye').body.should == 'Bye manveru'
|
69
|
+
get('/bye').body.should == 'Bye'
|
72
70
|
end
|
73
71
|
|
74
72
|
should 'work over multiple nodes' do
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
mock.get('/sub/bye').body.should == 'Bye '
|
73
|
+
get('/welcome').body.should == 'Welcome manveru'
|
74
|
+
get('/sub/bye').body.should == 'Bye manveru'
|
75
|
+
get('/sub/bye').body.should == 'Bye'
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
77
|
+
get('/sub/welcome').body.should == 'Welcome manveru'
|
78
|
+
get('/bye').body.should == 'Bye manveru'
|
79
|
+
get('/bye').body.should == 'Bye'
|
84
80
|
end
|
85
81
|
|
86
82
|
should 'check if flash is empty' do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
mock.get('/check_empty').body.should == 'true'
|
91
|
-
end
|
83
|
+
get('/welcome').body.should == 'Welcome manveru'
|
84
|
+
get('/check_empty').body.should == 'false'
|
85
|
+
get('/check_empty').body.should == 'true'
|
92
86
|
end
|
93
87
|
|
94
88
|
should 'set and delete key within one request' do
|
95
|
-
|
96
|
-
mock.get('/set_delete_key').body.should == ''
|
97
|
-
end
|
89
|
+
get('/set_delete_key').body.should == ''
|
98
90
|
end
|
99
91
|
|
100
92
|
should 'set and delete key over two request' do
|
101
|
-
|
102
|
-
|
103
|
-
mock.get('/delete_key').body.should == 'Bye '
|
104
|
-
end
|
93
|
+
get('/welcome').body.should == 'Welcome manveru'
|
94
|
+
get('/delete_key').body.should == 'Bye'
|
105
95
|
end
|
106
96
|
|
107
97
|
should 'merge with hash' do
|
108
|
-
|
109
|
-
|
110
|
-
mock.get('/bye').body.should == 'Bye '
|
111
|
-
end
|
98
|
+
get('/merge').body.should == {:name => 'feagliir'}.inspect
|
99
|
+
get('/bye').body.should == 'Bye'
|
112
100
|
end
|
113
101
|
|
114
102
|
should 'merge! with hash' do
|
115
|
-
|
116
|
-
|
117
|
-
mock.get('/bye').body.should == 'Bye feagliir'
|
118
|
-
end
|
103
|
+
get('/merge!').body.should == {:name => 'feagliir'}.inspect
|
104
|
+
get('/bye').body.should == 'Bye feagliir'
|
119
105
|
end
|
120
106
|
|
121
107
|
should 'inspect combined' do
|
122
|
-
|
123
|
-
|
124
|
-
mock.get('/inspect').body.
|
125
|
-
should == {:name => 'manveru', :yes => :yeah}.inspect
|
126
|
-
end
|
108
|
+
get('/welcome')
|
109
|
+
get('/inspect').body.should == {:name => 'manveru', :yes => :yeah}.inspect
|
127
110
|
end
|
128
111
|
|
129
112
|
should 'iterate over combined' do
|
130
|
-
|
131
|
-
mock.get('/welcome')
|
113
|
+
get('/welcome')
|
132
114
|
|
133
|
-
|
134
|
-
|
135
|
-
end
|
115
|
+
hash = {:yes => :yeah, :name => 'manveru'}
|
116
|
+
Hash[*eval(get('/iterate').body).flatten].should == hash
|
136
117
|
end
|
137
118
|
end
|
data/spec/innate/helper/link.rb
CHANGED
@@ -56,6 +56,14 @@ describe Innate::Helper::Link do
|
|
56
56
|
Two.route(:foo, :bar).should == URI('/two/foo/bar')
|
57
57
|
end
|
58
58
|
|
59
|
+
should 'respond with URI for node with path /foo/bar+baz' do
|
60
|
+
One.route('/foo/bar+baz').should == URI('/foo/bar+baz')
|
61
|
+
One.route(:foo, 'bar baz').should == URI('/foo/bar+baz')
|
62
|
+
|
63
|
+
Two.route('/foo/bar+baz').should == URI('/two/foo/bar+baz')
|
64
|
+
Two.route(:foo, 'bar baz').should == URI('/two/foo/bar+baz')
|
65
|
+
end
|
66
|
+
|
59
67
|
should 'respond with URI for node with GET params' do
|
60
68
|
One.route('/', :a => :b).should == URI('/?a=b')
|
61
69
|
|
@@ -20,7 +20,7 @@ class SpecRedirectHelper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def redirect_referer_action
|
23
|
-
redirect_referer
|
23
|
+
redirect_referer(r(:noop))
|
24
24
|
end
|
25
25
|
|
26
26
|
def no_actual_redirect
|
@@ -69,77 +69,92 @@ describe Innate::Helper::Redirect do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
should 'redirect' do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
get("#@uri/redirection")
|
73
|
+
|
74
|
+
last_response.status.should == 302
|
75
|
+
last_response.headers['Location'].should == "#@uri/index"
|
76
|
+
last_response.headers['Content-Type'].should == "text/html"
|
76
77
|
end
|
77
78
|
|
78
79
|
should 'redirect twice' do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
get("#@uri/double_redirection")
|
81
|
+
|
82
|
+
last_response.status.should == 302
|
83
|
+
last_response.headers['Location'].should == "#@uri/redirection"
|
84
|
+
last_response.headers['Content-Type'].should == "text/html"
|
83
85
|
end
|
84
86
|
|
85
87
|
should 'redirect to referer' do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
header 'HTTP_REFERER', '/index'
|
89
|
+
get("#@uri/redirect_referer_action")
|
90
|
+
|
91
|
+
last_response.status.should == 302
|
92
|
+
last_response.headers['Location'].should == "#@uri/index"
|
93
|
+
last_response.headers['Content-Type'].should == "text/html"
|
94
|
+
end
|
95
|
+
|
96
|
+
should 'redirect to fallback if referrer is identical' do
|
97
|
+
header 'HTTP_REFERER', "#@uri/redirect_referer_action"
|
98
|
+
get("#@uri/redirect_referer_action")
|
99
|
+
|
100
|
+
last_response.status.should == 302
|
101
|
+
last_response.headers['Location'].should == "#@uri/noop"
|
102
|
+
last_response.headers['Content-Type'].should == "text/html"
|
94
103
|
end
|
95
104
|
|
96
105
|
should 'use #r' do
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
106
|
+
get("#@uri/redirect_method")
|
107
|
+
|
108
|
+
last_response.status.should == 302
|
109
|
+
last_response.headers['Location'].should == "#@uri/noop"
|
110
|
+
last_response.headers['Content-Type'].should == "text/html"
|
101
111
|
end
|
102
112
|
|
103
113
|
should 'work with absolute uris' do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
114
|
+
get("#@uri/absolute_redirect")
|
115
|
+
|
116
|
+
last_response.status.should == 302
|
117
|
+
last_response.headers['Location'].should == "#@uri/noop"
|
118
|
+
last_response.headers['Content-Type'].should == "text/html"
|
108
119
|
end
|
109
120
|
|
110
121
|
should 'support #respond' do
|
111
|
-
|
112
|
-
|
113
|
-
|
122
|
+
get("#@uri/loop")
|
123
|
+
|
124
|
+
last_response.status.should == 200
|
125
|
+
last_response.body.should == 'no loop'
|
114
126
|
end
|
115
127
|
|
116
128
|
should 'support #respond with status' do
|
117
|
-
|
118
|
-
|
119
|
-
|
129
|
+
get("#@uri/respond_with_status")
|
130
|
+
|
131
|
+
last_response.status.should == 404
|
132
|
+
last_response.body.should == 'not found'
|
120
133
|
end
|
121
134
|
|
122
135
|
should 'support #respond!' do
|
123
|
-
|
124
|
-
|
125
|
-
|
136
|
+
get("#@uri/destructive_respond")
|
137
|
+
|
138
|
+
last_response.status.should == 200
|
139
|
+
last_response.body.should == 'destructive'
|
126
140
|
end
|
127
141
|
|
128
142
|
should 'redirect without modifying the target' do
|
129
|
-
|
130
|
-
|
131
|
-
|
143
|
+
get("#@uri/redirect_unmodified")
|
144
|
+
|
145
|
+
last_response.status.should == 302
|
146
|
+
last_response.headers['Location'].should == '/noop'
|
132
147
|
end
|
133
148
|
|
134
149
|
should 'catch redirection' do
|
135
|
-
|
136
|
-
|
137
|
-
|
150
|
+
get("#@uri/no_actual_redirect")
|
151
|
+
last_response.status.should == 200
|
152
|
+
last_response.body.should == 'no actual redirect'
|
138
153
|
end
|
139
154
|
|
140
155
|
should 'catch double redirect' do
|
141
|
-
|
142
|
-
|
143
|
-
|
156
|
+
get("#@uri/no_actual_double_redirect")
|
157
|
+
last_response.status.should == 200
|
158
|
+
last_response.body.should == 'no actual double redirect'
|
144
159
|
end
|
145
160
|
end
|