Sha256: c01709a748a95696d86ccbebe8b0207a60bca5e3b8a4f4a21a25c8bcd8feaf29
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require File.dirname(__FILE__) + '/helper' describe 'Registering extensions' do module FooExtensions def foo end private def im_hiding_in_ur_foos end end module BarExtensions def bar end end module BazExtensions def baz end end module QuuxExtensions def quux end end it 'will add the methods to the DSL for the class in which you register them and its subclasses' do Sinatra::Base.register FooExtensions assert Sinatra::Base.respond_to?(:foo) Sinatra::Default.register BarExtensions assert Sinatra::Default.respond_to?(:bar) assert Sinatra::Default.respond_to?(:foo) assert !Sinatra::Base.respond_to?(:bar) end it 'allows extending by passing a block' do Sinatra::Base.register { def im_in_ur_anonymous_module; end } assert Sinatra::Base.respond_to?(:im_in_ur_anonymous_module) end it 'will make sure any public methods added via Default#register are delegated to Sinatra::Delegator' do Sinatra::Default.register FooExtensions assert Sinatra::Delegator.private_instance_methods. map { |m| m.to_sym }.include?(:foo) assert !Sinatra::Delegator.private_instance_methods. map { |m| m.to_sym }.include?(:im_hiding_in_ur_foos) end it 'will not delegate methods on Base#register' do Sinatra::Base.register QuuxExtensions assert !Sinatra::Delegator.private_instance_methods.include?("quux") end it 'will extend the Sinatra::Default application by default' do Sinatra.register BazExtensions assert !Sinatra::Base.respond_to?(:baz) assert Sinatra::Default.respond_to?(:baz) end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
bmizerany-sinatra-0.9.0.5 | test/extensions_test.rb |
darkhelmet-sinatra-0.9.0.5 | test/extensions_test.rb |
sinatra-sinatra-0.9.0.5 | test/extensions_test.rb |