sinatra 0.9.0.5 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

@@ -10,47 +10,6 @@ class TesterWithEach
10
10
  end
11
11
  end
12
12
 
13
- context "Looking up a request" do
14
-
15
- setup do
16
- Sinatra.application = nil
17
- end
18
-
19
- # Deprecated. The lookup method is no longer used.
20
- xspecify "returns what's at the end" do
21
- block = Proc.new { 'Hello' }
22
- get '/', &block
23
-
24
- result = Sinatra.application.lookup(
25
- Rack::Request.new(
26
- 'REQUEST_METHOD' => 'GET',
27
- 'PATH_INFO' => '/'
28
- )
29
- )
30
-
31
- result.should.not.be.nil
32
- result.block.should.be block
33
- end
34
-
35
- # Deprecated. The lookup method is no longer used.
36
- xspecify "takes params in path" do
37
- block = Proc.new { 'Hello' }
38
- get '/:foo', &block
39
-
40
- result = Sinatra.application.lookup(
41
- Rack::Request.new(
42
- 'REQUEST_METHOD' => 'GET',
43
- 'PATH_INFO' => '/bar'
44
- )
45
- )
46
-
47
- result.should.not.be.nil
48
- result.block.should.be block
49
- result.params.should.equal "foo" => 'bar'
50
- end
51
-
52
- end
53
-
54
13
  context "An app returns" do
55
14
 
56
15
  setup do
@@ -85,20 +44,6 @@ context "An app returns" do
85
44
 
86
45
  end
87
46
 
88
- # Deprecated. The body method no longer halts.
89
- xspecify "the body set if set before the last" do
90
-
91
- get '/' do
92
- body 'Blake'
93
- 'Mizerany'
94
- end
95
-
96
- get_it '/'
97
- should.be.ok
98
- body.should.equal 'Blake'
99
-
100
- end
101
-
102
47
  specify "404 if NotFound is raised" do
103
48
 
104
49
  get '/' do
@@ -143,23 +88,6 @@ context "Application#configure blocks" do
143
88
 
144
89
  end
145
90
 
146
- context "Default Application Configuration" do
147
-
148
- # Sinatra::ServerError is no longer used
149
- xspecify "includes 404 and 500 error handlers" do
150
- Sinatra.application.errors.should.include(Sinatra::ServerError)
151
- Sinatra.application.errors[Sinatra::ServerError].should.not.be.nil
152
- Sinatra.application.errors.should.include(Sinatra::NotFound)
153
- Sinatra.application.errors[Sinatra::NotFound].should.not.be.nil
154
- end
155
-
156
- # Deprecated. No such thing as a Static event anymore.
157
- xspecify "includes Static event" do
158
- assert Sinatra.application.events[:get].any? { |e| Sinatra::Static === e }
159
- end
160
-
161
- end
162
-
163
91
  context "Events in an app" do
164
92
 
165
93
  setup do
@@ -23,32 +23,6 @@ context "Middleware Pipelines" do
23
23
  Sinatra.application = nil
24
24
  end
25
25
 
26
- # Sessions and logging are tested elsewhere. This is a bad test because it
27
- # asserts things about the implementation and not the effect.
28
- xspecify "includes default middleware with options set" do
29
- @app.set_options :sessions => true, :logging => true
30
- @app.send(:optional_middleware).should.include([Rack::Session::Cookie, [], nil])
31
- @app.send(:optional_middleware).should.include([Rack::CommonLogger, [], nil])
32
- end
33
-
34
- # Bad test.
35
- xspecify "does not include default middleware with options unset" do
36
- @app.set_options :sessions => false, :logging => false
37
- @app.send(:optional_middleware).should.not.include([Rack::Session::Cookie, [], nil])
38
- @app.send(:optional_middleware).should.not.include([Rack::CommonLogger, [], nil])
39
- end
40
-
41
- # Bad test.
42
- xspecify "includes only optional middleware when no explicit middleware added" do
43
- @app.set_options :sessions => true, :logging => true
44
- @app.send(:middleware).should.equal @app.send(:optional_middleware)
45
- end
46
-
47
- # Bad test.
48
- xspecify "should clear middleware before reload" do
49
- @app.clearables.should.include(@app.send(:explicit_middleware))
50
- end
51
-
52
26
  specify "should add middleware with use" do
53
27
  block = Proc.new { |env| }
54
28
  @app.use UpcaseMiddleware
@@ -21,6 +21,7 @@ context "Sessions" do
21
21
 
22
22
  specify "should be able to store data accross requests" do
23
23
  set_option :sessions, true
24
+ set_option :environment, :not_test # necessary because sessions are disabled
24
25
 
25
26
  get '/foo' do
26
27
  session[:test] = true
@@ -34,6 +35,8 @@ context "Sessions" do
34
35
  get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
35
36
  assert ok?
36
37
  assert include?('Set-Cookie')
38
+
39
+ set_option :environment, :test
37
40
  end
38
41
 
39
42
  end
@@ -93,7 +93,7 @@ context "SendData" do
93
93
  end
94
94
 
95
95
  # Deprecated. send_data is going away.
96
- xspecify "should send the data with options" do
96
+ specify "should send the data with options" do
97
97
  get '/' do
98
98
  send_data 'asdf', :status => 500
99
99
  end
@@ -107,7 +107,8 @@ context "SendData" do
107
107
  # Deprecated. The Content-Disposition is no longer handled by sendfile.
108
108
  specify "should include a Content-Disposition header" do
109
109
  get '/' do
110
- send_file File.dirname(__FILE__) + '/public/foo.xml'
110
+ send_file File.dirname(__FILE__) + '/public/foo.xml',
111
+ :disposition => 'attachment'
111
112
  end
112
113
 
113
114
  get_it '/'
@@ -115,7 +116,18 @@ context "SendData" do
115
116
  should.be.ok
116
117
  headers['Content-Disposition'].should.not.be.nil
117
118
  headers['Content-Disposition'].should.equal 'attachment; filename="foo.xml"'
118
- headers['Content-Transfer-Encoding'].should.equal 'binary'
119
119
  end
120
120
 
121
+ specify "should include a Content-Disposition header when :disposition set to attachment" do
122
+ get '/' do
123
+ send_file File.dirname(__FILE__) + '/public/foo.xml',
124
+ :disposition => 'attachment'
125
+ end
126
+
127
+ get_it '/'
128
+
129
+ should.be.ok
130
+ headers['Content-Disposition'].should.not.be.nil
131
+ headers['Content-Disposition'].should.equal 'attachment; filename="foo.xml"'
132
+ end
121
133
  end