mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
test delegation of Sinatra.register and Sinatra.helpers
This commit is contained in:
parent
cacd473801
commit
cbe5d15d42
2 changed files with 15 additions and 3 deletions
|
@ -1518,11 +1518,11 @@ module Sinatra
|
||||||
|
|
||||||
# Extend the top-level DSL with the modules provided.
|
# Extend the top-level DSL with the modules provided.
|
||||||
def self.register(*extensions, &block)
|
def self.register(*extensions, &block)
|
||||||
Application.register(*extensions, &block)
|
Delegator.target.register(*extensions, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Include the helper modules provided in Sinatra's request context.
|
# Include the helper modules provided in Sinatra's request context.
|
||||||
def self.helpers(*extensions, &block)
|
def self.helpers(*extensions, &block)
|
||||||
Application.helpers(*extensions, &block)
|
Delegator.target.helpers(*extensions, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DelegatorTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def delegate(&block)
|
def delegate(&block)
|
||||||
assert Sinatra::Delegator.target != Sinatra::Application
|
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
|
Sinatra::Delegator.target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,6 +88,18 @@ class DelegatorTest < Test::Unit::TestCase
|
||||||
assert_equal '', response.body
|
assert_equal '', response.body
|
||||||
end
|
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 'get'
|
||||||
delegates 'patch'
|
delegates 'patch'
|
||||||
delegates 'put'
|
delegates 'put'
|
||||||
|
|
Loading…
Reference in a new issue