diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index abff2d1f..dcde6bcd 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -1518,11 +1518,11 @@ module Sinatra # Extend the top-level DSL with the modules provided. def self.register(*extensions, &block) - Application.register(*extensions, &block) + Delegator.target.register(*extensions, &block) end # Include the helper modules provided in Sinatra's request context. def self.helpers(*extensions, &block) - Application.helpers(*extensions, &block) + Delegator.target.helpers(*extensions, &block) end end diff --git a/test/delegator_test.rb b/test/delegator_test.rb index 76f609e8..53de077f 100644 --- a/test/delegator_test.rb +++ b/test/delegator_test.rb @@ -46,7 +46,7 @@ class DelegatorTest < Test::Unit::TestCase def delegate(&block) assert Sinatra::Delegator.target != Sinatra::Application - Object.new.extend(Sinatra::Delegator).instance_eval(&block) + Object.new.extend(Sinatra::Delegator).instance_eval(&block) if block Sinatra::Delegator.target end @@ -88,6 +88,18 @@ class DelegatorTest < Test::Unit::TestCase assert_equal '', response.body end + it "registers extensions with the delegation target" do + app, mixin = mirror, Module.new + Sinatra.register mixin + assert_equal app.last_call, ["register", mixin.to_s ] + end + + it "registers helpers with the delegation target" do + app, mixin = mirror, Module.new + Sinatra.helpers mixin + assert_equal app.last_call, ["helpers", mixin.to_s ] + end + delegates 'get' delegates 'patch' delegates 'put'