spec/lib/registry_spec.rb in hieracles-0.3.6 vs spec/lib/registry_spec.rb in hieracles-0.4.0
- old
+ new
@@ -17,10 +17,31 @@
'dev4'
] }
it { expect(Hieracles::Registry.farms config).to eq expected }
end
+ describe '.farm_modules' do
+ let(:config) { Hieracles::Config.new options }
+ let(:expected) { {
+ 'dev' => [
+ "fake_module",
+ "fake_module2",
+ "fake_module3"
+ ],
+ 'dev2' => [
+ "fake_module",
+ "fake_module2",
+ "fake_module4"
+ ],
+ 'dev4' => [
+ "faux_module1",
+ "faux_module2"
+ ]
+ } }
+ it { expect(Hieracles::Registry.farms_modules config).to eq expected }
+ end
+
describe '.nodes' do
let(:expected) { [
'server.example.com',
'server2.example.com',
'server3.example.com',
@@ -34,11 +55,12 @@
let(:expected) { [
'fake_module',
'fake_module2',
'fake_module3',
'faux_module1',
- 'faux_module2'
+ 'faux_module2',
+ 'unused_module'
] }
let(:config) { Hieracles::Config.new options }
it { expect(Hieracles::Registry.modules config).to eq expected }
end
@@ -81,7 +103,35 @@
}
let(:config) { Hieracles::Config.new options }
it { expect(Hieracles::Registry.farms_counted config).to eq expected }
end
+ describe '.modules_counted' do
+ let(:expected) {
+ {
+ 'fake_module' => 2,
+ 'fake_module2' => 2,
+ 'fake_module3' => 1,
+ 'faux_module1' => 1,
+ 'faux_module2' => 1,
+ 'unused_module' => 0
+ }
+ }
+ let(:config) { Hieracles::Config.new options }
+ it { expect(Hieracles::Registry.modules_counted config).to eq expected }
+ end
+
+ describe '.find_item' do
+ let(:config) { Hieracles::Config.new options }
+ let(:expected) {
+ [
+ 'fake_module',
+ 'fake_module2',
+ 'fake_module3'
+ ]
+ }
+ let(:file) { format(config.classpath, 'dev') }
+ let(:regex) { Regexp.new('\s*include\s*([-_a-z0-9]*)') }
+ it { expect(Hieracles::Registry.find_item file, regex).to eq expected }
+ end
end