sinatra-sinatra 0.9.2 → 0.10.0

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.
Files changed (52) hide show
  1. data/CHANGES +1 -1
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -20
  4. data/lib/sinatra.rb +0 -1
  5. data/lib/sinatra/base.rb +4 -27
  6. data/sinatra.gemspec +4 -45
  7. data/test/server_test.rb +14 -10
  8. data/test/templates_test.rb +22 -0
  9. data/test/views/foo/hello.test +1 -0
  10. metadata +4 -46
  11. data/compat/app_test.rb +0 -282
  12. data/compat/application_test.rb +0 -262
  13. data/compat/builder_test.rb +0 -101
  14. data/compat/compat_test.rb +0 -12
  15. data/compat/custom_error_test.rb +0 -62
  16. data/compat/erb_test.rb +0 -136
  17. data/compat/events_test.rb +0 -78
  18. data/compat/filter_test.rb +0 -30
  19. data/compat/haml_test.rb +0 -236
  20. data/compat/helper.rb +0 -33
  21. data/compat/mapped_error_test.rb +0 -72
  22. data/compat/pipeline_test.rb +0 -45
  23. data/compat/public/foo.xml +0 -1
  24. data/compat/sass_test.rb +0 -67
  25. data/compat/sessions_test.rb +0 -42
  26. data/compat/streaming_test.rb +0 -133
  27. data/compat/sym_params_test.rb +0 -19
  28. data/compat/template_test.rb +0 -30
  29. data/compat/use_in_file_templates_test.rb +0 -47
  30. data/compat/views/foo.builder +0 -1
  31. data/compat/views/foo.erb +0 -1
  32. data/compat/views/foo.haml +0 -1
  33. data/compat/views/foo.sass +0 -2
  34. data/compat/views/foo_layout.erb +0 -2
  35. data/compat/views/foo_layout.haml +0 -2
  36. data/compat/views/layout_test/foo.builder +0 -1
  37. data/compat/views/layout_test/foo.erb +0 -1
  38. data/compat/views/layout_test/foo.haml +0 -1
  39. data/compat/views/layout_test/foo.sass +0 -2
  40. data/compat/views/layout_test/layout.builder +0 -3
  41. data/compat/views/layout_test/layout.erb +0 -1
  42. data/compat/views/layout_test/layout.haml +0 -1
  43. data/compat/views/layout_test/layout.sass +0 -2
  44. data/compat/views/no_layout/no_layout.builder +0 -1
  45. data/compat/views/no_layout/no_layout.haml +0 -1
  46. data/lib/sinatra/compat.rb +0 -266
  47. data/lib/sinatra/test.rb +0 -128
  48. data/lib/sinatra/test/bacon.rb +0 -19
  49. data/lib/sinatra/test/rspec.rb +0 -13
  50. data/lib/sinatra/test/spec.rb +0 -11
  51. data/lib/sinatra/test/unit.rb +0 -13
  52. data/test/test_test.rb +0 -152
data/CHANGES CHANGED
@@ -1,4 +1,4 @@
1
- = 0.9.2 / unreleased
1
+ = 0.9.2 / 2009-05-18
2
2
 
3
3
  * This version is compatible with Rack 1.0. [Rein Henrichs]
4
4
 
data/README.rdoc CHANGED
@@ -45,7 +45,7 @@ Route patterns may include named parameters, accessible via the
45
45
  <tt>params</tt> hash:
46
46
 
47
47
  get '/hello/:name' do
48
- # matches "GET /foo" and "GET /bar"
48
+ # matches "GET /hello/foo" and "GET /hello/bar"
49
49
  # params[:name] is 'foo' or 'bar'
50
50
  "Hello #{params[:name]}!"
51
51
  end
data/Rakefile CHANGED
@@ -2,35 +2,16 @@ require 'rake/clean'
2
2
  require 'rake/testtask'
3
3
  require 'fileutils'
4
4
 
5
- task :default => [:test, :compat]
5
+ task :default => :test
6
6
  task :spec => :test
7
7
 
8
8
  # SPECS ===============================================================
9
9
 
10
- task(:test) { puts "==> Running main test suite" }
11
-
12
10
  Rake::TestTask.new(:test) do |t|
13
11
  t.test_files = FileList['test/*_test.rb']
14
12
  t.ruby_opts = ['-rubygems'] if defined? Gem
15
13
  end
16
14
 
17
- desc "Run < 0.9.x compatibility specs"
18
- task :compat do
19
- begin
20
- require 'mocha'
21
- require 'test/spec'
22
- at_exit { exit 0 } # disable test-spec at_exit runner
23
-
24
- puts "==> Running compat test suite"
25
- Rake::TestTask.new(:compat) do |t|
26
- t.test_files = FileList['compat/*_test.rb']
27
- t.ruby_opts = ['-rubygems'] if defined? Gem
28
- end
29
- rescue LoadError
30
- warn 'Skipping compat tests. mocha and/or test-spec gems not installed.'
31
- end
32
- end
33
-
34
15
  # PACKAGING ============================================================
35
16
 
36
17
  # Load the gemspec using the same limitations as github
data/lib/sinatra.rb CHANGED
@@ -3,6 +3,5 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
3
 
4
4
  require 'sinatra/base'
5
5
  require 'sinatra/main'
6
- require 'sinatra/compat'
7
6
 
8
7
  use_in_file_templates!
data/lib/sinatra/base.rb CHANGED
@@ -6,7 +6,7 @@ require 'rack/builder'
6
6
  require 'sinatra/showexceptions'
7
7
 
8
8
  module Sinatra
9
- VERSION = '0.9.2'
9
+ VERSION = '0.10.0'
10
10
 
11
11
  # The request object. See Rack::Request for more info:
12
12
  # http://rack.rubyforge.org/doc/classes/Rack/Request.html
@@ -43,7 +43,7 @@ module Sinatra
43
43
  body = [body] if body.respond_to? :to_str
44
44
  if body.respond_to?(:to_ary)
45
45
  header["Content-Length"] = body.to_ary.
46
- inject(0) { |len, part| len + part.bytesize }.to_s
46
+ inject(0) { |len, part| len + Rack::Utils.bytesize(part) }.to_s
47
47
  end
48
48
  [status.to_i, header.to_hash, body]
49
49
  end
@@ -223,27 +223,19 @@ module Sinatra
223
223
  # in the template
224
224
  module Templates
225
225
  def erb(template, options={}, locals={})
226
- require_warn('ERB') unless defined?(::ERB)
227
-
228
226
  render :erb, template, options, locals
229
227
  end
230
228
 
231
229
  def haml(template, options={}, locals={})
232
- require_warn('Haml') unless defined?(::Haml::Engine)
233
-
234
230
  render :haml, template, options, locals
235
231
  end
236
232
 
237
233
  def sass(template, options={}, locals={})
238
- require_warn('Sass') unless defined?(::Sass::Engine)
239
-
240
234
  options[:layout] = false
241
235
  render :sass, template, options, locals
242
236
  end
243
237
 
244
238
  def builder(template=nil, options={}, locals={}, &block)
245
- require_warn('Builder') unless defined?(::Builder)
246
-
247
239
  options, template = template, nil if template.is_a?(Hash)
248
240
  template = lambda { block } if template.nil?
249
241
  render :builder, template, options, locals
@@ -268,7 +260,7 @@ module Sinatra
268
260
  if layout
269
261
  data, options[:filename], options[:line] = lookup_layout(engine, layout, views)
270
262
  if data
271
- output = __send__("render_#{engine}", layout, data, options, {}) { output }
263
+ output = __send__("render_#{engine}", layout, data, options, locals) { output }
272
264
  end
273
265
  end
274
266
 
@@ -339,11 +331,6 @@ module Sinatra
339
331
  end
340
332
  xml.target!
341
333
  end
342
-
343
- def require_warn(engine)
344
- warn "Auto-require of #{engine} is deprecated; add require '#{engine}' to your app."
345
- require engine.downcase
346
- end
347
334
  end
348
335
 
349
336
  # Base class for all Sinatra applications and middleware.
@@ -922,7 +909,7 @@ module Sinatra
922
909
  servers = Array(self.server)
923
910
  servers.each do |server_name|
924
911
  begin
925
- return Rack::Handler.get(server_name.capitalize)
912
+ return Rack::Handler.get(server_name.downcase)
926
913
  rescue LoadError
927
914
  rescue NameError
928
915
  end
@@ -1106,13 +1093,3 @@ module Sinatra
1106
1093
  Default.helpers(*extensions, &block)
1107
1094
  end
1108
1095
  end
1109
-
1110
- class String #:nodoc:
1111
- # Define String#each under 1.9 for Rack compatibility. This should be
1112
- # removed once Rack is fully 1.9 compatible.
1113
- alias_method :each, :each_line unless ''.respond_to? :each
1114
-
1115
- # Define String#bytesize as an alias to String#length for Ruby 1.8.6 and
1116
- # earlier.
1117
- alias_method :bytesize, :length unless ''.respond_to? :bytesize
1118
- end
data/sinatra.gemspec CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'sinatra'
6
- s.version = '0.9.2'
7
- s.date = '2009-05-18'
6
+ s.version = '0.10.0'
7
+ s.date = '2009-06-05'
8
8
 
9
9
  s.description = "Classy web-development dressed in a DSL"
10
10
  s.summary = "Classy web-development dressed in a DSL"
@@ -19,53 +19,12 @@ Gem::Specification.new do |s|
19
19
  LICENSE
20
20
  README.rdoc
21
21
  Rakefile
22
- compat/app_test.rb
23
- compat/application_test.rb
24
- compat/builder_test.rb
25
- compat/compat_test.rb
26
- compat/custom_error_test.rb
27
- compat/erb_test.rb
28
- compat/events_test.rb
29
- compat/filter_test.rb
30
- compat/haml_test.rb
31
- compat/helper.rb
32
- compat/mapped_error_test.rb
33
- compat/pipeline_test.rb
34
- compat/public/foo.xml
35
- compat/sass_test.rb
36
- compat/sessions_test.rb
37
- compat/streaming_test.rb
38
- compat/sym_params_test.rb
39
- compat/template_test.rb
40
- compat/use_in_file_templates_test.rb
41
- compat/views/foo.builder
42
- compat/views/foo.erb
43
- compat/views/foo.haml
44
- compat/views/foo.sass
45
- compat/views/foo_layout.erb
46
- compat/views/foo_layout.haml
47
- compat/views/layout_test/foo.builder
48
- compat/views/layout_test/foo.erb
49
- compat/views/layout_test/foo.haml
50
- compat/views/layout_test/foo.sass
51
- compat/views/layout_test/layout.builder
52
- compat/views/layout_test/layout.erb
53
- compat/views/layout_test/layout.haml
54
- compat/views/layout_test/layout.sass
55
- compat/views/no_layout/no_layout.builder
56
- compat/views/no_layout/no_layout.haml
57
22
  lib/sinatra.rb
58
23
  lib/sinatra/base.rb
59
- lib/sinatra/compat.rb
60
24
  lib/sinatra/images/404.png
61
25
  lib/sinatra/images/500.png
62
26
  lib/sinatra/main.rb
63
27
  lib/sinatra/showexceptions.rb
64
- lib/sinatra/test.rb
65
- lib/sinatra/test/bacon.rb
66
- lib/sinatra/test/rspec.rb
67
- lib/sinatra/test/spec.rb
68
- lib/sinatra/test/unit.rb
69
28
  sinatra.gemspec
70
29
  test/base_test.rb
71
30
  test/builder_test.rb
@@ -91,11 +50,11 @@ Gem::Specification.new do |s|
91
50
  test/sinatra_test.rb
92
51
  test/static_test.rb
93
52
  test/templates_test.rb
94
- test/test_test.rb
95
53
  test/views/error.builder
96
54
  test/views/error.erb
97
55
  test/views/error.haml
98
56
  test/views/error.sass
57
+ test/views/foo/hello.test
99
58
  test/views/hello.builder
100
59
  test/views/hello.erb
101
60
  test/views/hello.haml
@@ -111,7 +70,7 @@ Gem::Specification.new do |s|
111
70
  s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
112
71
 
113
72
  s.extra_rdoc_files = %w[README.rdoc LICENSE]
114
- s.add_dependency 'rack', '>= 0.9.1'
73
+ s.add_dependency 'rack', '>= 1.0'
115
74
  s.add_development_dependency 'shotgun', '>= 0.2', '< 1.0'
116
75
  s.add_development_dependency 'rack-test', '>= 0.3.0'
117
76
 
data/test/server_test.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- class Rack::Handler::Mock
4
- extend Test::Unit::Assertions
5
-
6
- def self.run(app, options={})
7
- assert(app < Sinatra::Base)
8
- assert_equal 9001, options[:Port]
9
- assert_equal 'foo.local', options[:Host]
10
- yield new
3
+ module Rack::Handler
4
+ class Mock
5
+ extend Test::Unit::Assertions
6
+
7
+ def self.run(app, options={})
8
+ assert(app < Sinatra::Base)
9
+ assert_equal 9001, options[:Port]
10
+ assert_equal 'foo.local', options[:Host]
11
+ yield new
12
+ end
13
+
14
+ def stop
15
+ end
11
16
  end
12
17
 
13
- def stop
14
- end
18
+ register 'mock', 'Rack::Handler::Mock'
15
19
  end
16
20
 
17
21
  class ServerTest < Test::Unit::TestCase
@@ -76,6 +76,12 @@ class TemplatesTest < Test::Unit::TestCase
76
76
  assert_equal "X\n= yield\nX\n", @app.templates[:layout][:template]
77
77
  end
78
78
 
79
+ it 'loads templates from specified views directory' do
80
+ render_app { render :test, :hello, :views => options.views + '/foo' }
81
+
82
+ assert_equal "from another views directory\n", body
83
+ end
84
+
79
85
  test 'use_in_file_templates simply ignores IO errors' do
80
86
  assert_nothing_raised {
81
87
  mock_app {
@@ -85,6 +91,22 @@ class TemplatesTest < Test::Unit::TestCase
85
91
 
86
92
  assert @app.templates.empty?
87
93
  end
94
+
95
+ it 'passes locals to the layout' do
96
+ mock_app {
97
+ template :my_layout do
98
+ 'Hello <%= name %>!<%= yield %>'
99
+ end
100
+
101
+ get '/' do
102
+ erb '<p>content</p>', { :layout => :my_layout }, { :name => 'Mike'}
103
+ end
104
+ }
105
+
106
+ get '/'
107
+ assert ok?
108
+ assert_equal 'Hello Mike!<p>content</p>', body
109
+ end
88
110
  end
89
111
 
90
112
  # __END__ : this is not the real end of the script.
@@ -0,0 +1 @@
1
+ from another views directory
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-18 00:00:00 -07:00
12
+ date: 2009-06-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.1
23
+ version: "1.0"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shotgun
@@ -60,53 +60,12 @@ files:
60
60
  - LICENSE
61
61
  - README.rdoc
62
62
  - Rakefile
63
- - compat/app_test.rb
64
- - compat/application_test.rb
65
- - compat/builder_test.rb
66
- - compat/compat_test.rb
67
- - compat/custom_error_test.rb
68
- - compat/erb_test.rb
69
- - compat/events_test.rb
70
- - compat/filter_test.rb
71
- - compat/haml_test.rb
72
- - compat/helper.rb
73
- - compat/mapped_error_test.rb
74
- - compat/pipeline_test.rb
75
- - compat/public/foo.xml
76
- - compat/sass_test.rb
77
- - compat/sessions_test.rb
78
- - compat/streaming_test.rb
79
- - compat/sym_params_test.rb
80
- - compat/template_test.rb
81
- - compat/use_in_file_templates_test.rb
82
- - compat/views/foo.builder
83
- - compat/views/foo.erb
84
- - compat/views/foo.haml
85
- - compat/views/foo.sass
86
- - compat/views/foo_layout.erb
87
- - compat/views/foo_layout.haml
88
- - compat/views/layout_test/foo.builder
89
- - compat/views/layout_test/foo.erb
90
- - compat/views/layout_test/foo.haml
91
- - compat/views/layout_test/foo.sass
92
- - compat/views/layout_test/layout.builder
93
- - compat/views/layout_test/layout.erb
94
- - compat/views/layout_test/layout.haml
95
- - compat/views/layout_test/layout.sass
96
- - compat/views/no_layout/no_layout.builder
97
- - compat/views/no_layout/no_layout.haml
98
63
  - lib/sinatra.rb
99
64
  - lib/sinatra/base.rb
100
- - lib/sinatra/compat.rb
101
65
  - lib/sinatra/images/404.png
102
66
  - lib/sinatra/images/500.png
103
67
  - lib/sinatra/main.rb
104
68
  - lib/sinatra/showexceptions.rb
105
- - lib/sinatra/test.rb
106
- - lib/sinatra/test/bacon.rb
107
- - lib/sinatra/test/rspec.rb
108
- - lib/sinatra/test/spec.rb
109
- - lib/sinatra/test/unit.rb
110
69
  - sinatra.gemspec
111
70
  - test/base_test.rb
112
71
  - test/builder_test.rb
@@ -132,11 +91,11 @@ files:
132
91
  - test/sinatra_test.rb
133
92
  - test/static_test.rb
134
93
  - test/templates_test.rb
135
- - test/test_test.rb
136
94
  - test/views/error.builder
137
95
  - test/views/error.erb
138
96
  - test/views/error.haml
139
97
  - test/views/error.sass
98
+ - test/views/foo/hello.test
140
99
  - test/views/hello.builder
141
100
  - test/views/hello.erb
142
101
  - test/views/hello.haml
@@ -199,4 +158,3 @@ test_files:
199
158
  - test/sinatra_test.rb
200
159
  - test/static_test.rb
201
160
  - test/templates_test.rb
202
- - test/test_test.rb
data/compat/app_test.rb DELETED
@@ -1,282 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- context "Sinatra" do
4
-
5
- setup do
6
- Sinatra.application = nil
7
- end
8
-
9
- specify "should put all DSL methods on (main)" do
10
- object = Object.new
11
- methods = %w[get put post head delete configure template helpers set]
12
- methods.each do |method|
13
- object.private_methods.map { |m| m.to_sym }.should.include(method.to_sym)
14
- end
15
- end
16
-
17
- specify "should handle result of nil" do
18
- get '/' do
19
- nil
20
- end
21
-
22
- get_it '/'
23
- should.be.ok
24
- body.should == ''
25
- end
26
-
27
- specify "handles events" do
28
- get '/:name' do
29
- 'Hello ' + params["name"]
30
- end
31
-
32
- get_it '/Blake'
33
-
34
- should.be.ok
35
- body.should.equal 'Hello Blake'
36
- end
37
-
38
-
39
- specify "handles splats" do
40
- get '/hi/*' do
41
- params["splat"].kind_of?(Array).should.equal true
42
- params["splat"].first
43
- end
44
-
45
- get_it '/hi/Blake'
46
-
47
- should.be.ok
48
- body.should.equal 'Blake'
49
- end
50
-
51
- specify "handles multiple splats" do
52
- get '/say/*/to/*' do
53
- params["splat"].join(' ')
54
- end
55
-
56
- get_it '/say/hello/to/world'
57
-
58
- should.be.ok
59
- body.should.equal 'hello world'
60
- end
61
-
62
- specify "allow empty splats" do
63
- get '/say/*/to*/*' do
64
- params["splat"].join(' ')
65
- end
66
-
67
- get_it '/say/hello/to/world'
68
-
69
- should.be.ok
70
- body.should.equal 'hello world' # second splat is empty
71
-
72
- get_it '/say/hello/tomy/world'
73
-
74
- should.be.ok
75
- body.should.equal 'hello my world'
76
- end
77
-
78
- specify "gives access to underlying response header Hash" do
79
- get '/' do
80
- header['X-Test'] = 'Is this thing on?'
81
- headers 'X-Test2' => 'Foo', 'X-Test3' => 'Bar'
82
- ''
83
- end
84
-
85
- get_it '/'
86
- should.be.ok
87
- headers.should.include 'X-Test'
88
- headers['X-Test'].should.equal 'Is this thing on?'
89
- headers.should.include 'X-Test3'
90
- headers['X-Test3'].should.equal 'Bar'
91
- end
92
-
93
- specify "follows redirects" do
94
- get '/' do
95
- redirect '/blake'
96
- end
97
-
98
- get '/blake' do
99
- 'Mizerany'
100
- end
101
-
102
- get_it '/'
103
- should.be.redirection
104
- body.should.equal ''
105
-
106
- follow!
107
- should.be.ok
108
- body.should.equal 'Mizerany'
109
- end
110
-
111
- specify "renders a body with a redirect" do
112
- helpers do
113
- def foo ; 'blah' ; end
114
- end
115
- get "/" do
116
- redirect 'foo', :foo
117
- end
118
- get_it '/'
119
- should.be.redirection
120
- headers['Location'].should.equal 'foo'
121
- body.should.equal 'blah'
122
- end
123
-
124
- specify "redirects permanently with 301 status code" do
125
- get "/" do
126
- redirect 'foo', 301
127
- end
128
- get_it '/'
129
- should.be.redirection
130
- headers['Location'].should.equal 'foo'
131
- status.should.equal 301
132
- body.should.be.empty
133
- end
134
-
135
- specify "stop sets content and ends event" do
136
- get '/set_body' do
137
- stop 'Hello!'
138
- stop 'World!'
139
- fail 'stop should have halted'
140
- end
141
-
142
- get_it '/set_body'
143
-
144
- should.be.ok
145
- body.should.equal 'Hello!'
146
-
147
- end
148
-
149
- specify "should easily set response Content-Type" do
150
- get '/foo.html' do
151
- content_type 'text/html', :charset => 'utf-8'
152
- "<h1>Hello, World</h1>"
153
- end
154
-
155
- get_it '/foo.html'
156
- should.be.ok
157
- headers['Content-Type'].should.equal 'text/html;charset=utf-8'
158
- body.should.equal '<h1>Hello, World</h1>'
159
-
160
- get '/foo_test.xml' do
161
- content_type :xml
162
- "<feed></feed>"
163
- end
164
-
165
- get_it '/foo_test.xml'
166
- should.be.ok
167
- headers['Content-Type'].should.equal 'application/xml'
168
- body.should.equal '<feed></feed>'
169
- end
170
-
171
- specify "supports conditional GETs with last_modified" do
172
- modified_at = Time.now
173
- get '/maybe' do
174
- last_modified modified_at
175
- 'response body, maybe'
176
- end
177
-
178
- get_it '/maybe'
179
- should.be.ok
180
- body.should.equal 'response body, maybe'
181
-
182
- get_it '/maybe', :env => { 'HTTP_IF_MODIFIED_SINCE' => modified_at.httpdate }
183
- status.should.equal 304
184
- body.should.equal ''
185
- end
186
-
187
- specify "supports conditional GETs with entity_tag" do
188
- get '/strong' do
189
- entity_tag 'FOO'
190
- 'foo response'
191
- end
192
-
193
- get_it '/strong'
194
- should.be.ok
195
- body.should.equal 'foo response'
196
-
197
- get_it '/strong', {},
198
- 'HTTP_IF_NONE_MATCH' => '"BAR"'
199
- should.be.ok
200
- body.should.equal 'foo response'
201
-
202
- get_it '/strong', {},
203
- 'HTTP_IF_NONE_MATCH' => '"FOO"'
204
- status.should.equal 304
205
- body.should.equal ''
206
-
207
- get_it '/strong', {},
208
- 'HTTP_IF_NONE_MATCH' => '"BAR", *'
209
- status.should.equal 304
210
- body.should.equal ''
211
- end
212
-
213
- specify "delegates HEAD requests to GET handlers" do
214
- get '/invisible' do
215
- "I am invisible to the world"
216
- end
217
-
218
- head_it '/invisible'
219
- should.be.ok
220
- body.should.not.equal "I am invisible to the world"
221
- body.should.equal ''
222
- end
223
-
224
-
225
- specify "supports PUT" do
226
- put '/' do
227
- 'puted'
228
- end
229
- put_it '/'
230
- assert_equal 'puted', body
231
- end
232
-
233
- specify "rewrites POSTs with _method param to PUT" do
234
- put '/' do
235
- 'puted'
236
- end
237
- post_it '/', :_method => 'PUT'
238
- assert_equal 'puted', body
239
- end
240
-
241
- specify "rewrites POSTs with lowercase _method param to PUT" do
242
- put '/' do
243
- 'puted'
244
- end
245
- post_it '/', :_method => 'put'
246
- body.should.equal 'puted'
247
- end
248
-
249
- specify "does not rewrite GETs with _method param to PUT" do
250
- get '/' do
251
- 'getted'
252
- end
253
- get_it '/', :_method => 'put'
254
- should.be.ok
255
- body.should.equal 'getted'
256
- end
257
-
258
- specify "ignores _method query string parameter on non-POST requests" do
259
- post '/' do
260
- 'posted'
261
- end
262
- put '/' do
263
- 'booo'
264
- end
265
- post_it "/?_method=PUT"
266
- should.be.ok
267
- body.should.equal 'posted'
268
- end
269
-
270
- specify "does not read body if content type is not url encoded" do
271
- post '/foo.xml' do
272
- request.env['CONTENT_TYPE'].should.be == 'application/xml'
273
- request.content_type.should.be == 'application/xml'
274
- request.body.read
275
- end
276
-
277
- post_it '/foo.xml', '<foo></foo>', :content_type => 'application/xml'
278
- @response.should.be.ok
279
- @response.body.should.be == '<foo></foo>'
280
- end
281
-
282
- end