1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

FIX: Allow event to return nil without failure

This commit is contained in:
Blake Mizerany 2008-02-19 19:51:39 -08:00
parent 038b6b7df2
commit 24377ca50c
2 changed files with 12 additions and 1 deletions

View file

@ -357,7 +357,8 @@ module Sinatra
[:complete, context.instance_eval(&result.block)]
end
body = returned.to_result(context)
context.body = String === body ? [*body] : body
body = '' unless body.respond_to?(:each)
context.body = body.kind_of?(String) ? [*body] : body
context.finish
rescue => e
raise e if options.raise_errors

View file

@ -6,6 +6,16 @@ context "Sinatra" do
Sinatra.application = nil
end
specify "should handle result of nil" do
get '/' do
nil
end
get_it '/'
should.be.ok
body.should == ''
end
specify "handles events" do
get '/:name' do
'Hello ' + params[:name]