summaryrefslogtreecommitdiff
path: root/spec/unit/util/dsc/configuration_generator_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/util/dsc/configuration_generator_spec.rb')
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb84
1 files changed, 42 insertions, 42 deletions
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index 9fbd3aaa51..f05780285f 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -16,25 +16,25 @@
# limitations under the License.
#
-require 'chef'
-require 'chef/util/dsc/configuration_generator'
+require "chef"
+require "chef/util/dsc/configuration_generator"
describe Chef::Util::DSC::ConfigurationGenerator do
let(:conf_man) do
node = Chef::Node.new
- Chef::Util::DSC::ConfigurationGenerator.new(node, 'tmp')
+ Chef::Util::DSC::ConfigurationGenerator.new(node, "tmp")
end
describe '#validate_configuration_name!' do
- it 'should not raise an error if a name contains all upper case letters' do
+ it "should not raise an error if a name contains all upper case letters" do
conf_man.send(:validate_configuration_name!, "HELLO")
end
- it 'should not raise an error if the name contains all lower case letters' do
+ it "should not raise an error if the name contains all lower case letters" do
conf_man.send(:validate_configuration_name!, "hello")
end
- it 'should not raise an error if no special characters are used except _' do
+ it "should not raise an error if no special characters are used except _" do
conf_man.send(:validate_configuration_name!, "hello_world")
end
@@ -48,67 +48,67 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
describe "#get_merged_configuration_flags" do
- context 'when strings are used as switches' do
- it 'should merge the hash if there are no restricted switches' do
- merged = conf_man.send(:get_merged_configuration_flags!, {'flag' => 'a'}, 'hello')
+ context "when strings are used as switches" do
+ it "should merge the hash if there are no restricted switches" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {"flag" => "a"}, "hello")
expect(merged).to include(:flag)
- expect(merged[:flag]).to eql('a')
+ expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
end
- it 'should raise an ArgumentError if you try to override outputpath' do
+ it "should raise an ArgumentError if you try to override outputpath" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {'outputpath' => 'a'}, 'hello')
+ conf_man.send(:get_merged_configuration_flags!, {"outputpath" => "a"}, "hello")
}.to raise_error(ArgumentError)
end
- it 'should be case insensitive for switches that are not allowed' do
+ it "should be case insensitive for switches that are not allowed" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {'OutputPath' => 'a'}, 'hello')
+ conf_man.send(:get_merged_configuration_flags!, {"OutputPath" => "a"}, "hello")
}.to raise_error(ArgumentError)
end
- it 'should be case insensitive to switches that are allowed' do
- merged = conf_man.send(:get_merged_configuration_flags!, {'FLAG' => 'a'}, 'hello')
+ it "should be case insensitive to switches that are allowed" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {"FLAG" => "a"}, "hello")
expect(merged).to include(:flag)
end
end
- context 'when symbols are used as switches' do
- it 'should merge the hash if there are no restricted switches' do
- merged = conf_man.send(:get_merged_configuration_flags!, {:flag => 'a'}, 'hello')
+ context "when symbols are used as switches" do
+ it "should merge the hash if there are no restricted switches" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {:flag => "a"}, "hello")
expect(merged).to include(:flag)
- expect(merged[:flag]).to eql('a')
+ expect(merged[:flag]).to eql("a")
expect(merged).to include(:outputpath)
end
- it 'should raise an ArgumentError if you try to override outputpath' do
+ it "should raise an ArgumentError if you try to override outputpath" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {:outputpath => 'a'}, 'hello')
+ conf_man.send(:get_merged_configuration_flags!, {:outputpath => "a"}, "hello")
}.to raise_error(ArgumentError)
end
- it 'should be case insensitive for switches that are not allowed' do
+ it "should be case insensitive for switches that are not allowed" do
expect {
- conf_man.send(:get_merged_configuration_flags!, {:OutputPath => 'a'}, 'hello')
+ conf_man.send(:get_merged_configuration_flags!, {:OutputPath => "a"}, "hello")
}.to raise_error(ArgumentError)
end
- it 'should be case insensitive to switches that are allowed' do
- merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => 'a'}, 'hello')
+ it "should be case insensitive to switches that are allowed" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => "a"}, "hello")
expect(merged).to include(:flag)
end
end
- context 'when there are no flags' do
- it 'should supply an output path if configuration_flags is an empty hash' do
- merged = conf_man.send(:get_merged_configuration_flags!, {}, 'hello')
+ context "when there are no flags" do
+ it "should supply an output path if configuration_flags is an empty hash" do
+ merged = conf_man.send(:get_merged_configuration_flags!, {}, "hello")
expect(merged).to include(:outputpath)
expect(merged.length).to eql(1)
end
- it 'should supply an output path if configuration_flags is an empty hash' do
- merged = conf_man.send(:get_merged_configuration_flags!, nil, 'hello')
+ it "should supply an output path if configuration_flags is an empty hash" do
+ merged = conf_man.send(:get_merged_configuration_flags!, nil, "hello")
expect(merged).to include(:outputpath)
expect(merged.length).to eql(1)
end
@@ -130,7 +130,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
[a,b].join("++")
end
allow(file_like_object).to receive(:write)
- conf_man.send(:write_document_generation_script, 'file', 'hello', {})
+ conf_man.send(:write_document_generation_script, "file", "hello", {})
expect(file_like_object).to have_received(:write)
end
end
@@ -143,24 +143,24 @@ describe Chef::Util::DSC::ConfigurationGenerator do
[a,b].join("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'hello.mof', 'f3']}
- expect(conf_man.send(:find_configuration_document, 'hello')).to eql('tmp++hello++hello.mof')
+ allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "hello.mof", "f3"]}
+ expect(conf_man.send(:find_configuration_document, "hello")).to eql("tmp++hello++hello.mof")
end
it "should return nil if the mof file is not found" do
allow(File).to receive(:join) do |a, b|
[a,b].join("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'f3']}
- expect(conf_man.send(:find_configuration_document, 'hello')).to be_nil
+ allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "f3"]}
+ expect(conf_man.send(:find_configuration_document, "hello")).to be_nil
end
end
describe "#configuration_code" do
it "should build dsc" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {})
found_configuration = false
- dsc.split(';').each do |command|
+ dsc.split(";").each do |command|
if command.downcase =~ /\s*configuration\s+'hello'\s*\{\s*node\s+'localhost'\s*\{\s*archive\s*\{\s*\}\s*\}\s*\}\s*/
found_configuration = true
end
@@ -169,22 +169,22 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
context "with imports" do
it "should import all resources when a module has an empty list" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => []})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => []})
expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/)
end
it "should import all resources when a module has a list with *" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', '*', 'BarResource']})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "*", "BarResource"]})
expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/)
end
it "should import specific resources when a module has list without * that is not empty" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource']})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"]})
expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/)
end
it "should import multiple modules with multiple import statements" do
- dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource'], 'BazModule' => []})
+ dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"], "BazModule" => []})
expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/)
expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/)
end