/
micelaneous_spec.rb
65 lines (54 loc) · 1.71 KB
/
micelaneous_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'spec_helper'
describe "Micelaneous" do
with_load_path "#{spec_dir}/autoload/lib"
before{self.micon = Micon::Core.new}
after{remove_constants :TheRouter, :TheRad}
describe "autoloading" do
it "should autoload component definition" do
micon[:some_value].should == "some_value"
end
# it 'should autoload component - constants (and nested constants)' do
# TheRouter.should == "TheRouter"
# module ::TheRad; end
# TheRad::TheView.should == "TheView"
# end
end
describe "complex circullar dependencies" do
it "should not initialize twice (from error)" do
micon.register :kit do
micon[:kit]
'kit'
end
lambda{micon[:kit]}.should raise_error(/component :kit used before it's initialization is finished/)
end
it "should not initialize twice if called from dependency (from error)" do
micon.register :environment do
micon[:router]
'environment'
end
micon.register :router, depends_on: :environment do
'router'
end
-> {micon[:router]}.should raise_error(/component :router used before it's initialization is finished/)
end
it "should allow to use circullar dependency in :after callback" do
check = mock
check.should_receive(:initialized).once
micon.register :kit do
check.initialized
'kit'
end
micon.after :kit do
micon[:kit]
end
micon[:kit].should == 'kit'
end
end
it "helper method generation" do
micon.register :router
micon.router?.should be_false
micon.router = 'router'
micon.router?.should be_true
micon.router.should == 'router'
end
end