4 include Merb::Global::DateProviders::Base
7 module Merb::Global::DateProviders
11 @@providers_classes = {}
13 def self.provider= provider
18 describe Merb::Global::DateProviders do
20 Merb::Global::DateProviders.clear
22 describe '.provider' do
23 it 'should return fork as default' do
25 Merb::Global.expects(:config).with(:date_provider, 'fork').
27 Merb::Global::DateProviders.expects(:[]).with('fork').returns(provider)
28 Merb::Global::DateProviders.provider.should == provider
31 it 'should return the name of the provider in config' do
33 Merb::Global.expects(:config).with(:date_provider, 'fork').
35 Merb::Global::DateProviders.expects(:[]).with('name').
37 Merb::Global::DateProviders.provider.should == provider
40 it 'should return cached provider' do
42 Merb::Global::DateProviders.provider = provider
43 Merb::Global::DateProviders.provider.should == provider
48 describe Merb::Global::DateProviders::Base do
50 @provider = TestDateProvider.new
53 describe '.localize' do
54 it 'should raise NoMethodError' do
56 @provider.localize 'en', Date.new, '%A'
57 end.should raise_error(NoMethodError)
62 describe 'Merb::Global.DateProvider' do
63 it 'should create a module' do
65 Module.expects(:new).returns(mod)
66 Merb::Global.DateProvider(:test).should == mod
69 it 'should include base only' do
70 Module.any_instance.expects(:include).
71 with(Merb::Global::DateProviders::Base)
72 Merb::Global.DateProvider(:test1)
75 it 'should register when include' do
77 Merb::Global::DateProviders.expects(:register).with(:test2, klass)
78 klass.instance_eval do
79 include Merb::Global.DateProvider(:test2)