diff --git a/lib/sinatra/main.rb b/lib/sinatra/main.rb index fc6ac70d..1d1d9cd3 100644 --- a/lib/sinatra/main.rb +++ b/lib/sinatra/main.rb @@ -25,4 +25,6 @@ module Sinatra at_exit { Application.run! if $!.nil? && Application.run? } end -include Sinatra::Delegator +# include would include the module in Object +# extend only extends the `main` object +extend Sinatra::Delegator diff --git a/test/integration/app.rb b/test/integration/app.rb index b13d6e99..8f98c55a 100644 --- a/test/integration/app.rb +++ b/test/integration/app.rb @@ -1,6 +1,20 @@ require 'sinatra' +configure do + set :foo, :bar +end + get '/app_file' do content_type :txt settings.app_file -end \ No newline at end of file +end + +get '/mainonly' do + object = Object.new + begin + object.send(:get, '/foo') { } + 'false' + rescue NameError + 'true' + end +end diff --git a/test/integration_test.rb b/test/integration_test.rb index fab592c7..f3de1f98 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -44,9 +44,13 @@ class IntegrationTest < Test::Unit::TestCase Process.kill("TERM", pipe.pid) if pipe end - it 'starts a top level application' do + def assert_content(url, content) with_server do - assert_equal open("http://127.0.0.1:#{port}/app_file").read, app_file + response = open("http://127.0.0.1:#{port}#{url}") + assert_equal response.read, content end end + + it('sets the app_file') { assert_content "/app_file", app_file } + it('only extends main') { assert_content "/mainonly", "true" } end