summaryrefslogtreecommitdiff
path: root/spec/unit/util
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-17 12:15:26 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-08-17 13:25:02 -0700
commita0c32511bc6634538374ca4b433032b8acd05f96 (patch)
tree15c7cfbd0d773488ab814e7c24f0c58505c9134b /spec/unit/util
parent3d0379a2ad531a0b3db5ed2827bf30ef07b26100 (diff)
downloadchef-a0c32511bc6634538374ca4b433032b8acd05f96.tar.gz
fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgrade
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb24
-rw-r--r--spec/unit/util/dsc/local_configuration_manager_spec.rb21
-rw-r--r--spec/unit/util/dsc/resource_store.rb14
-rw-r--r--spec/unit/util/editor_spec.rb12
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb20
5 files changed, 48 insertions, 43 deletions
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index 12f62deb5a..cfa7a4e264 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
Chef::Util::DSC::ConfigurationGenerator.new(node, "tmp")
end
- describe '#validate_configuration_name!' do
+ describe "#validate_configuration_name!" do
it "should not raise an error if a name contains all upper case letters" do
conf_man.send(:validate_configuration_name!, "HELLO")
end
@@ -40,9 +40,9 @@ describe Chef::Util::DSC::ConfigurationGenerator do
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
it "raises an Argument error if it configuration name contains #{sym}" do
- expect {
+ expect do
conf_man.send(:validate_configuration_name!, "Hello#{sym}")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
end
@@ -57,15 +57,15 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
it "should raise an ArgumentError if you try to override outputpath" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { "outputpath" => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { "OutputPath" => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
@@ -83,15 +83,15 @@ describe Chef::Util::DSC::ConfigurationGenerator do
end
it "should raise an ArgumentError if you try to override outputpath" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive for switches that are not allowed" do
- expect {
+ expect do
conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "should be case insensitive to switches that are allowed" do
@@ -121,7 +121,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
#
end
- describe '#write_document_generation_script' do
+ describe "#write_document_generation_script" do
let(:file_like_object) { double("file like object") }
it "should write the input to a file" do
diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb
index 15cf38394e..45fe8df40d 100644
--- a/spec/unit/util/dsc/local_configuration_manager_spec.rb
+++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb
@@ -23,15 +23,17 @@ describe Chef::Util::DSC::LocalConfigurationManager do
let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, "tmp") }
- let(:normal_lcm_output) { <<-EOH
+ let(:normal_lcm_output) do
+ <<-EOH
logtype: [machinename]: LCM: [ Start Set ]
logtype: [machinename]: LCM: [ Start Resource ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOH
- }
+ end
- let(:no_whatif_lcm_output) { <<-EOH
+ let(:no_whatif_lcm_output) do
+ <<-EOH
Start-DscConfiguration : A parameter cannot be found\r\n that matches parameter name 'whatif'.
At line:1 char:123
+ run-somecommand -whatif
@@ -39,16 +41,17 @@ At line:1 char:123
+ CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand
EOH
- }
+ end
- let(:dsc_resource_import_failure_output) { <<-EOH
+ let(:dsc_resource_import_failure_output) do
+ <<-EOH
PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : .
EOH
- }
+ end
- let(:lcm_status) {
+ let(:lcm_status) do
double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success)
- }
+ end
describe "test_configuration method invocation" do
context "when interacting with the LCM using a PowerShell cmdlet" do
@@ -77,7 +80,7 @@ EOH
let(:lcm_standard_error) { no_whatif_lcm_output }
let(:lcm_cmdlet_success) { false }
- it 'returns true when passed to #whatif_not_supported?' do
+ it "returns true when passed to #whatif_not_supported?" do
expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy
end
diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb
index 84b39190b2..a864a2c1da 100644
--- a/spec/unit/util/dsc/resource_store.rb
+++ b/spec/unit/util/dsc/resource_store.rb
@@ -21,28 +21,30 @@ require "chef/util/dsc/resource_store"
describe Chef::Util::DSC::ResourceStore do
let(:resource_store) { Chef::Util::DSC::ResourceStore.new }
- let(:resource_a) { {
+ let(:resource_a) do
+ {
"ResourceType" => "AFoo",
"Name" => "Foo",
"Module" => { "Name" => "ModuleA" },
}
- }
+ end
- let(:resource_b) { {
+ let(:resource_b) do
+ {
"ResourceType" => "BFoo",
"Name" => "Foo",
"Module" => { "Name" => "ModuleB" },
}
- }
+ end
context "when resources are not cached" do
- context 'when calling #resources' do
+ context "when calling #resources" do
it "returns an empty array" do
expect(resource_store.resources).to eql([])
end
end
- context 'when calling #find' do
+ context "when calling #find" do
it "returns an empty list if it cannot find any matching resources" do
expect(resource_store).to receive(:query_resource).and_return([])
expect(resource_store.find("foo")).to eql([])
diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb
index 7a0ec91533..e53bc9662a 100644
--- a/spec/unit/util/editor_spec.rb
+++ b/spec/unit/util/editor_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
require "chef/util/editor"
describe Chef::Util::Editor do
- describe '#initialize' do
+ describe "#initialize" do
it "takes an Enumerable of lines" do
editor = described_class.new(File.open(__FILE__))
expect(editor.lines).to be == IO.readlines(__FILE__)
@@ -18,7 +18,7 @@ describe Chef::Util::Editor do
subject(:editor) { described_class.new(input_lines) }
let(:input_lines) { %w{one two two three} }
- describe '#append_line_after' do
+ describe "#append_line_after" do
context "when there is no match" do
subject(:execute) { editor.append_line_after("missing", "new") }
@@ -44,7 +44,7 @@ describe Chef::Util::Editor do
end
end
- describe '#append_line_if_missing' do
+ describe "#append_line_if_missing" do
context "when there is no match" do
subject(:execute) { editor.append_line_if_missing("missing", "new") }
@@ -70,7 +70,7 @@ describe Chef::Util::Editor do
end
end
- describe '#remove_lines' do
+ describe "#remove_lines" do
context "when there is no match" do
subject(:execute) { editor.remove_lines("missing") }
@@ -96,7 +96,7 @@ describe Chef::Util::Editor do
end
end
- describe '#replace' do
+ describe "#replace" do
context "when there is no match" do
subject(:execute) { editor.replace("missing", "new") }
@@ -123,7 +123,7 @@ describe Chef::Util::Editor do
end
end
- describe '#replace_lines' do
+ describe "#replace_lines" do
context "when there is no match" do
subject(:execute) { editor.replace_lines("missing", "new") }
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index 5c0e66aee2..800e4cc9c0 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Util::Powershell::Cmdlet do
@cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Some-Commandlet")
end
- describe '#validate_switch_name!' do
+ describe "#validate_switch_name!" do
it "should not raise an error if a name contains all upper case letters" do
@cmdlet.send(:validate_switch_name!, "HELLO")
end
@@ -40,14 +40,14 @@ describe Chef::Util::Powershell::Cmdlet do
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
it "raises an Argument error if it configuration name contains #{sym}" do
- expect {
+ expect do
@cmdlet.send(:validate_switch_name!, "Hello#{sym}")
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
end
end
- describe '#escape_parameter_value' do
+ describe "#escape_parameter_value" do
# Is this list really complete?
%w{` " # '}.each do |c|
it "escapse #{c}" do
@@ -60,23 +60,23 @@ describe Chef::Util::Powershell::Cmdlet do
end
end
- describe '#escape_string_parameter_value' do
+ describe "#escape_string_parameter_value" do
it "surrounds a string with ''" do
expect(@cmdlet.send(:escape_string_parameter_value, "stuff")).to eql("'stuff'")
end
end
- describe '#command_switches_string' do
+ describe "#command_switches_string" do
it "raises an ArgumentError if the key is not a symbol" do
- expect {
+ expect do
@cmdlet.send(:command_switches_string, { "foo" => "bar" })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "does not allow invalid switch names" do
- expect {
+ expect do
@cmdlet.send(:command_switches_string, { :foo! => "bar" })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
end
it "ignores switches with a false value" do