/
manager_test.rb
56 lines (48 loc) · 1.9 KB
/
manager_test.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
require File.join(File.dirname(__FILE__), 'test_helper')
class Core::ManagerTest < Test::Unit::TestCase
before(:all) { eval "module ::Base; end" }
before(:each) { Core::Manager.reset_libraries }
test "creates library with a hash" do
lib = {:base_class=>"Funky", :base_path=>"funky/ext" }
Core::Manager.create_library(lib)
Core::Manager.libraries[:funky].should == lib
end
test "creates library with a hash but no base_class" do
lib = {:base_path=>"funky/ext", :monkeypatch=>true}
Core::Manager.create_library(lib)
Core::Manager.libraries[:funky].should == lib
end
test "creates library with base class" do
lib = {:base_class=>::Base, :base_path=>"base"}
Core::Manager.create_library(::Base)
Core::Manager.libraries[:base].should == lib
end
context "when setting default library" do
test "with class fetches existing one" do
Core::Manager.create_library(::Base)
Core::Manager.default_library = ::Base
lib = {:base_class=>::Base, :base_path=>"base"}
Core::Manager.default_library.should == lib
end
test "with class creates new one" do
eval "module ::Base2; end"
Core::Manager.default_library = ::Base2
lib = {:base_class=>::Base2, :base_path=>"base2"}
Core::Manager.default_library.should == lib
end
test "with hash creates new one one" do
lib = {:base_class=>::Base, :base_path=>"base"}
Core::Manager.default_library = lib
Core::Manager.default_library.should == lib
end
test "with symbol fetches existing one" do
Core::Manager.create_library(::Base)
Core::Manager.default_library = :base
lib = {:base_class=>::Base, :base_path=>"base"}
Core::Manager.default_library.should == lib
end
test "with invalid symbol warns nothing found" do
capture_stdout {Core::Manager.default_library = :blah}.should =~ /not found/
end
end
end