manveru-innate 2009.03.24 → 2009.04

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/CHANGELOG +354 -0
  2. data/MANIFEST +34 -22
  3. data/README.md +2 -10
  4. data/Rakefile +30 -247
  5. data/example/app/retro_games.rb +8 -8
  6. data/example/app/todo/layout/{default.erb → default.xhtml} +1 -1
  7. data/example/app/todo/view/{index.erb → index.xhtml} +11 -11
  8. data/example/app/whywiki_erb/start.rb +2 -1
  9. data/example/app/whywiki_erb/view/{edit.html.erb → edit.erb} +0 -0
  10. data/example/app/whywiki_erb/view/{index.html.erb → index.erb} +0 -0
  11. data/example/howto_spec.rb +1 -1
  12. data/example/provides.rb +9 -6
  13. data/example/session.rb +3 -3
  14. data/innate.gemspec +23 -127
  15. data/lib/innate/action.rb +24 -13
  16. data/lib/innate/adapter.rb +5 -27
  17. data/lib/innate/cache/file_based.rb +2 -0
  18. data/lib/innate/cache.rb +1 -1
  19. data/lib/innate/current.rb +5 -5
  20. data/lib/innate/dynamap.rb +5 -0
  21. data/lib/innate/helper/cgi.rb +32 -19
  22. data/lib/innate/helper/link.rb +2 -2
  23. data/lib/innate/helper/redirect.rb +1 -1
  24. data/lib/innate/helper/render.rb +87 -0
  25. data/lib/innate/helper/send_file.rb +9 -1
  26. data/lib/innate/helper.rb +20 -29
  27. data/lib/innate/log/hub.rb +1 -1
  28. data/lib/innate/middleware_compiler.rb +1 -15
  29. data/lib/innate/mock.rb +2 -3
  30. data/lib/innate/node.rb +85 -55
  31. data/lib/innate/options/dsl.rb +1 -1
  32. data/lib/innate/options.rb +1 -1
  33. data/lib/innate/request.rb +3 -76
  34. data/lib/innate/response.rb +1 -8
  35. data/lib/innate/session.rb +2 -3
  36. data/lib/innate/spec.rb +6 -50
  37. data/lib/innate/version.rb +1 -1
  38. data/lib/innate/view/erb.rb +1 -5
  39. data/lib/innate/view/etanni.rb +36 -0
  40. data/lib/innate/view/none.rb +1 -1
  41. data/lib/innate/view.rb +14 -16
  42. data/lib/innate.rb +27 -53
  43. data/spec/example/app/retro_games.rb +30 -0
  44. data/spec/example/provides.rb +16 -0
  45. data/spec/example/session.rb +8 -14
  46. data/spec/innate/action/layout/file_layout.xhtml +1 -0
  47. data/spec/innate/action/layout.rb +1 -1
  48. data/spec/innate/helper/aspect.rb +6 -6
  49. data/spec/innate/helper/flash.rb +28 -47
  50. data/spec/innate/helper/link.rb +8 -0
  51. data/spec/innate/helper/redirect.rb +58 -43
  52. data/spec/innate/helper/render.rb +133 -0
  53. data/spec/innate/helper/view/aspect_hello.xhtml +1 -0
  54. data/spec/innate/helper/view/locals.xhtml +1 -0
  55. data/spec/innate/helper/view/loop.xhtml +4 -0
  56. data/spec/innate/helper/view/num.xhtml +1 -0
  57. data/spec/innate/helper/view/partial.xhtml +1 -0
  58. data/spec/innate/helper/view/recursive.xhtml +7 -0
  59. data/spec/innate/node/node.rb +5 -13
  60. data/spec/innate/node/view/another_layout/{another_layout.erb → another_layout.xhtml} +1 -1
  61. data/spec/innate/node/view/{bar.erb → bar.xhtml} +0 -0
  62. data/spec/innate/node/view/foo.html.xhtml +1 -0
  63. data/spec/innate/node/view/{only_view.erb → only_view.xhtml} +0 -0
  64. data/spec/innate/node/view/with_layout.xhtml +1 -0
  65. data/spec/innate/provides/list.html.xhtml +1 -0
  66. data/spec/innate/provides/list.txt.xhtml +1 -0
  67. data/spec/innate/provides.rb +2 -2
  68. data/spec/innate/request.rb +0 -9
  69. data/spec/innate/session.rb +14 -15
  70. data/spec/innate/state/fiber.rb +8 -7
  71. data/tasks/bacon.rake +66 -0
  72. data/tasks/changelog.rake +18 -0
  73. data/tasks/gem.rake +22 -0
  74. data/tasks/gem_installer.rake +76 -0
  75. data/tasks/grancher.rake +12 -0
  76. data/tasks/install_dependencies.rake +4 -0
  77. data/tasks/manifest.rake +4 -0
  78. data/tasks/rcov.rake +19 -0
  79. data/tasks/release.rake +51 -0
  80. data/tasks/reversion.rake +8 -0
  81. data/tasks/setup.rake +28 -0
  82. metadata +41 -38
  83. data/lib/innate/core_compatibility/basic_object.rb +0 -10
  84. data/lib/innate/core_compatibility/string.rb +0 -3
  85. data/lib/innate/helper/partial.rb +0 -93
  86. data/spec/innate/action/layout/file_layout.erb +0 -1
  87. data/spec/innate/helper/partial.rb +0 -101
  88. data/spec/innate/helper/view/aspect_hello.erb +0 -1
  89. data/spec/innate/helper/view/locals.erb +0 -1
  90. data/spec/innate/helper/view/loop.erb +0 -4
  91. data/spec/innate/helper/view/num.erb +0 -1
  92. data/spec/innate/helper/view/partial.erb +0 -1
  93. data/spec/innate/helper/view/recursive.erb +0 -8
  94. data/spec/innate/node/view/foo.html.erb +0 -1
  95. data/spec/innate/node/view/with_layout.erb +0 -1
  96. data/spec/innate/provides/list.html.erb +0 -1
  97. 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
- # Exceptions are:
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 :handler [Symbol] (:webrick)
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
- if found_root = go_figure_root(:root => root, :file => file)
117
- $0 = found_root
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 => '/path/to/here'
177
+ # Innate.start :root => File.dirname(__FILE__)
186
178
  #
187
- # In case these options are not passed we will try to figure out a file named
188
- # `start.rb` in the backtrace and use the directory it resides in.
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
- # TODO: better documentation and nice defaults, don't want to rely on a
191
- # filename, bad mojo.
192
- def go_figure_root(options, backtrace = caller)
193
- if o_file = options[:file]
194
- return File.dirname(o_file)
195
- elsif root = options[:root]
196
- return root
197
- end
198
-
199
- pwd = Dir.pwd
200
-
201
- return pwd if File.file?(File.join(pwd, 'start.rb'))
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::Head, Rack::Reloader)
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 =&gt; 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 =&gt; 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
@@ -2,27 +2,21 @@ require 'spec/helper'
2
2
  require 'example/session'
3
3
 
4
4
  describe 'example/session' do
5
- behaves_like :session
5
+ behaves_like :mock
6
6
 
7
7
  it 'starts at 0' do
8
- session do |mock|
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
- session do |mock|
15
- mock.get('/increment').should =~ /Value is: 1/
16
- mock.get('/increment').should =~ /Value is: 2/
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
- session do |mock|
23
- mock.get('/decrement').should =~ /Value is: -1/
24
- mock.get('/decrement').should =~ /Value is: -2/
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>
@@ -13,7 +13,7 @@ class SpecActionLayoutMethod < SpecActionLayout
13
13
  layout('method_layout')
14
14
 
15
15
  def method_layout
16
- "<pre><%= @content %></pre>"
16
+ '<pre>#{ @content }</pre>'
17
17
  end
18
18
 
19
19
  def index
@@ -38,25 +38,25 @@ end
38
38
  describe Innate::Helper::Aspect do
39
39
  behaves_like :mock
40
40
 
41
- should 'execute before aspect' do
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
- should 'execute after asepct' do
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
- should 'execute wrap aspects' do
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
- should 'before_all and after_all' do
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
- should 'instance variables in blocks available to view/method' do
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!\n"
73
+ get('/without_method/aspect_hello').body.should == "Hello World!"
74
74
  end
75
75
  end
@@ -57,81 +57,62 @@ class SpecFlashSub < SpecFlash
57
57
  end
58
58
 
59
59
  describe Innate::Helper::Flash do
60
- behaves_like :session
60
+ behaves_like :mock
61
61
 
62
62
  should 'set and forget flash twice' do
63
- session do |mock|
64
- mock.get('/welcome').body.should == 'Welcome manveru'
65
- mock.get('/bye').body.should == 'Bye manveru'
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
- mock.get('/welcome').body.should == 'Welcome manveru'
69
- mock.get('/bye').body.should == 'Bye manveru'
70
- mock.get('/bye').body.should == 'Bye '
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
- session do |mock|
76
- mock.get('/welcome').body.should == 'Welcome manveru'
77
- mock.get('/sub/bye').body.should == 'Bye manveru'
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
- mock.get('/sub/welcome').body.should == 'Welcome manveru'
81
- mock.get('/bye').body.should == 'Bye manveru'
82
- mock.get('/bye').body.should == 'Bye '
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
- session do |mock|
88
- mock.get('/welcome').body.should == 'Welcome manveru'
89
- mock.get('/check_empty').body.should == 'false'
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
- session do |mock|
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
- session do |mock|
102
- mock.get('/welcome').body.should == 'Welcome manveru'
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
- session do |mock|
109
- mock.get('/merge').body.should == {:name => 'feagliir'}.inspect
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
- session do |mock|
116
- mock.get('/merge!').body.should == {:name => 'feagliir'}.inspect
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
- session do |mock|
123
- mock.get('/welcome')
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
- session do |mock|
131
- mock.get('/welcome')
113
+ get('/welcome')
132
114
 
133
- hash = {:yes => :yeah, :name => 'manveru'}
134
- Hash[*eval(mock.get('/iterate').body).flatten].should == hash
135
- end
115
+ hash = {:yes => :yeah, :name => 'manveru'}
116
+ Hash[*eval(get('/iterate').body).flatten].should == hash
136
117
  end
137
118
  end
@@ -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
- got = get("#@uri/redirection")
73
- got.status.should == 302
74
- got.headers['Location'].should == "#@uri/index"
75
- got.headers['Content-Type'].should == "text/html"
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
- got = get("#@uri/double_redirection")
80
- got.status.should == 302
81
- got.headers['Location'].should == "#@uri/redirection"
82
- got.headers['Content-Type'].should == "text/html"
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
- got = get("#@uri/redirect_referer_action", 'HTTP_REFERER' => '/noop')
87
- got.status.should == 302
88
- got.headers['Location'].should == "#@uri/noop"
89
- got.headers['Content-Type'].should == "text/html"
90
- got = get("#@uri/redirect_referer_action", 'HTTP_REFERER' => "#@uri/redirect_referer_action")
91
- got.status.should == 302
92
- got.headers['Location'].should == "#@uri/"
93
- got.headers['Content-Type'].should == "text/html"
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
- got = get("#@uri/redirect_method")
98
- got.status.should == 302
99
- got.headers['Location'].should == "#@uri/noop"
100
- got.headers['Content-Type'].should == "text/html"
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
- got = get("#@uri/absolute_redirect")
105
- got.status.should == 302
106
- got.headers['Location'].should == "#@uri/noop"
107
- got.headers['Content-Type'].should == "text/html"
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
- got = get("#@uri/loop")
112
- got.status.should == 200
113
- got.body.should == 'no loop'
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
- got = get("#@uri/respond_with_status")
118
- got.status.should == 404
119
- got.body.should == 'not found'
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
- got = get("#@uri/destructive_respond")
124
- got.status.should == 200
125
- got.body.should == 'destructive'
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
- got = get("#@uri/redirect_unmodified")
130
- got.status.should == 302
131
- got.headers['Location'].should == '/noop'
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
- got = get("#@uri/no_actual_redirect")
136
- got.status.should == 200
137
- got.body.should == 'no actual redirect'
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
- got = get("#@uri/no_actual_double_redirect")
142
- got.status.should == 200
143
- got.body.should == 'no actual double redirect'
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