summaryrefslogtreecommitdiff
path: root/spec/unit/mixin
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/mixin')
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb15
-rw-r--r--spec/unit/mixin/checksum_spec.rb1
-rw-r--r--spec/unit/mixin/command_spec.rb14
-rw-r--r--spec/unit/mixin/deep_merge_spec.rb202
-rw-r--r--spec/unit/mixin/params_validate_spec.rb68
-rw-r--r--spec/unit/mixin/path_sanity_spec.rb12
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb4
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb8
-rw-r--r--spec/unit/mixin/proxified_socket_spec.rb2
-rw-r--r--spec/unit/mixin/securable_spec.rb2
-rw-r--r--spec/unit/mixin/shell_out_spec.rb6
-rw-r--r--spec/unit/mixin/template_spec.rb7
-rw-r--r--spec/unit/mixin/uris_spec.rb2
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb23
14 files changed, 182 insertions, 184 deletions
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index 0768072814..13b729538c 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -23,8 +23,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
let(:object) { dummy_class.new }
describe ".server_client_api_version_intersection" do
- let(:default_supported_client_versions) { [0,1,2] }
-
+ let(:default_supported_client_versions) { [0, 1, 2] }
context "when the response code is not 406" do
let(:response) { OpenStruct.new(:code => "405") }
@@ -78,13 +77,13 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when all the versions are higher than the max" do
it_should_behave_like "no intersection between client and server versions" do
- let(:supported_client_versions) { [5,6,7] }
+ let(:supported_client_versions) { [5, 6, 7] }
end
end
context "when all the versions are lower than the min" do
it_should_behave_like "no intersection between client and server versions" do
- let(:supported_client_versions) { [0,1] }
+ let(:supported_client_versions) { [0, 1] }
end
end
@@ -92,16 +91,16 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when there is an intersection between client and server versions" do
context "when multiple versions intersect" do
- let(:supported_client_versions) { [1,2,3,4,5] }
+ let(:supported_client_versions) { [1, 2, 3, 4, 5] }
it "includes all of the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
- to eq([2,3,4])
+ to eq([2, 3, 4])
end
end # when multiple versions intersect
context "when only the min client version intersects" do
- let(:supported_client_versions) { [0,1,2] }
+ let(:supported_client_versions) { [0, 1, 2] }
it "includes the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
@@ -110,7 +109,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
end # when only the min client version intersects
context "when only the max client version intersects" do
- let(:supported_client_versions) { [4,5,6] }
+ let(:supported_client_versions) { [4, 5, 6] }
it "includes the intersection" do
expect(object.server_client_api_version_intersection(exception, supported_client_versions)).
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index 8b8284a867..997dcd523e 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -38,4 +38,3 @@ describe Chef::Mixin::Checksum do
end
end
-
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb
index dfe7b148ec..0c2f6da188 100644
--- a/spec/unit/mixin/command_spec.rb
+++ b/spec/unit/mixin/command_spec.rb
@@ -43,16 +43,16 @@ describe Chef::Mixin::Command, :volatile do
end
it "should respect locale when specified explicitly" do
- popen4("echo $LC_ALL", :environment => {"LC_ALL" => "es"}) do |pid, stdin, stdout, stderr|
+ popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr|
expect(stdout.read.strip).to eq("es")
end
end
it "should end when the child process reads from STDIN and a block is given" do
expect {Timeout.timeout(10) do
- popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
- (1..5).each { |i| stdin.puts "#{i}" }
- end
+ popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr|
+ (1..5).each { |i| stdin.puts "#{i}" }
+ end
end
}.not_to raise_error
end
@@ -61,8 +61,8 @@ describe Chef::Mixin::Command, :volatile do
it "returns immediately after the first child process exits" do
expect {Timeout.timeout(10) do
- evil_forker="exit if fork; 10.times { sleep 1}"
- popen4("ruby -e '#{evil_forker}'") do |pid,stdin,stdout,stderr|
+ evil_forker = "exit if fork; 10.times { sleep 1}"
+ popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr|
end
end}.not_to raise_error
end
@@ -93,7 +93,7 @@ describe Chef::Mixin::Command, :volatile do
# Serdar - During Solaris tests, we've seen that processes
# are taking a long time to exit. Bumping timeout now to 10.
expect {Timeout.timeout(10) do
- evil_forker="exit if fork; 10.times { sleep 1}"
+ evil_forker = "exit if fork; 10.times { sleep 1}"
run_command(:command => "ruby -e '#{evil_forker}'")
end}.not_to raise_error
end
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb
index 6ce9a1cb2d..2850193eb6 100644
--- a/spec/unit/mixin/deep_merge_spec.rb
+++ b/spec/unit/mixin/deep_merge_spec.rb
@@ -34,14 +34,14 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do
# deep_merge core tests - moving from basic to more complex
it "tests merging an hash w/array into blank hash" do
- hash_src = {"id" => "2"}
+ hash_src = { "id" => "2" }
hash_dst = {}
@dm.deep_merge!(hash_src.dup, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests merging an hash w/array into blank hash" do
- hash_src = {"region" => {"id" => ["227", "2"]}}
+ hash_src = { "region" => { "id" => ["227", "2"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
@@ -49,192 +49,192 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do
it "tests merge from empty hash" do
hash_src = {}
- hash_dst = {"property" => ["2","4"]}
+ hash_dst = { "property" => ["2", "4"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4"] })
end
it "tests merge to empty hash" do
- hash_src = {"property" => ["2","4"]}
+ hash_src = { "property" => ["2", "4"] }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4"] })
end
it "tests simple string overwrite" do
- hash_src = {"name" => "value"}
- hash_dst = {"name" => "value1"}
+ hash_src = { "name" => "value" }
+ hash_dst = { "name" => "value1" }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"name" => "value"})
+ expect(hash_dst).to eq({ "name" => "value" })
end
it "tests simple string overwrite of empty hash" do
- hash_src = {"name" => "value"}
+ hash_src = { "name" => "value" }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests hashes holding array" do
- hash_src = {"property" => ["1","3"]}
- hash_dst = {"property" => ["2","4"]}
+ hash_src = { "property" => ["1", "3"] }
+ hash_dst = { "property" => ["2", "4"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => ["2","4","1","3"]})
+ expect(hash_dst).to eq({ "property" => ["2", "4", "1", "3"] })
end
it "tests hashes holding hashes holding arrays (array with duplicate elements is merged with dest then src" do
- hash_src = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["3", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["3", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["3","2","1"], "bathroom_count" => ["2", "1", "4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["3", "2", "1"], "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding array v string (string is overwritten by array)" do
- hash_src = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => "3", "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding string v array (array is overwritten by string)" do
- hash_src = {"property" => {"bedroom_count" => "3", "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => "3", "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => "3", "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => "3", "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests hash holding hash holding hash v array (array is overwritten by hash)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => ["1", "2"], "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 3 hash layers holding integers (integers are overwritten by source)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => 2, "queen_bed" => 4}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => 2, "queen_bed" => 4 }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => 1}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => 1 }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 3 hash layers holding arrays of int (arrays are merged)" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3], "queen_bed" => [1]}, "bathroom_count" => ["1", "4+"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3], "queen_bed" => [1] }, "bathroom_count" => ["1", "4+"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4,1]}, "bathroom_count" => ["2","1","4+"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4, 1] }, "bathroom_count" => ["2", "1", "4+"] } })
end
it "tests 1 hash overwriting 3 hash layers holding arrays of int" do
- hash_src = {"property" => "1"}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => "1" }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => "1"})
+ expect(hash_dst).to eq({ "property" => "1" })
end
it "tests 3 hash layers holding arrays of int (arrays are merged) but second hash's array is overwritten" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3], "queen_bed" => [1]}, "bathroom_count" => "1"}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3], "queen_bed" => [1] }, "bathroom_count" => "1" } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4,1]}, "bathroom_count" => "1"}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4, 1] }, "bathroom_count" => "1" } })
end
it "tests 3 hash layers holding arrays of int, but one holds int. This one overwrites, but the rest merge" do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => [1]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [1] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => 3, "queen_bed" => [4,1]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => 3, "queen_bed" => [4, 1] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is incomplete." do
- hash_src = {"property" => {"bedroom_count" => {"king_bed" => [3]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { "king_bed" => [3] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2,3], "queen_bed" => [4]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is shorter and has new 2nd level ints." do
- hash_src = {"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_src = { "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } }
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {2=>3, "king_bed" => [2,3], "queen_bed" => [4]}, "bathroom_count" => ["2","1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [2, 3], "queen_bed" => [4] }, "bathroom_count" => ["2", "1"] } })
end
it "tests 3 hash layers holding arrays of int, but source is empty" do
hash_src = {}
- hash_dst = {"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}}
+ hash_dst = { "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {"king_bed" => [2], "queen_bed" => [4]}, "bathroom_count" => ["2"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { "king_bed" => [2], "queen_bed" => [4] }, "bathroom_count" => ["2"] } })
end
it "tests 3 hash layers holding arrays of int, but dest is empty" do
- hash_src = {"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}}
+ hash_src = { "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => {2=>3, "king_bed" => [3]}, "bathroom_count" => ["1"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => { 2 => 3, "king_bed" => [3] }, "bathroom_count" => ["1"] } })
end
it "tests hash holding arrays of arrays" do
- hash_src = {["1", "2", "3"] => ["1", "2"]}
- hash_dst = {["4", "5"] => ["3"]}
+ hash_src = { ["1", "2", "3"] => ["1", "2"] }
+ hash_dst = { ["4", "5"] => ["3"] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({["1","2","3"] => ["1", "2"], ["4", "5"] => ["3"]})
+ expect(hash_dst).to eq({ ["1", "2", "3"] => ["1", "2"], ["4", "5"] => ["3"] })
end
it "tests merging of hash with blank hash, and make sure that source array split does not function when turned off" do
- hash_src = {"property" => {"bedroom_count" => ["1","2,3"]}}
+ hash_src = { "property" => { "bedroom_count" => ["1", "2,3"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"property" => {"bedroom_count" => ["1","2,3"]}})
+ expect(hash_dst).to eq({ "property" => { "bedroom_count" => ["1", "2,3"] } })
end
it "tests merging into a blank hash" do
- hash_src = {"action"=>"browse", "controller"=>"results"}
+ hash_src = { "action" => "browse", "controller" => "results" }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
expect(hash_dst).to eq(hash_src)
end
it "tests are unmerged hashes passed unmodified w/out :unpack_arrays?" do
- hash_src = {"amenity"=>{"id"=>["26,27"]}}
+ hash_src = { "amenity" => { "id" => ["26,27"] } }
hash_dst = {}
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"amenity"=>{"id"=>["26,27"]}})
+ expect(hash_dst).to eq({ "amenity" => { "id" => ["26,27"] } })
end
it "tests hash of array of hashes" do
- hash_src = {"item" => [{"1" => "3"}, {"2" => "4"}]}
- hash_dst = {"item" => [{"3" => "5"}]}
+ hash_src = { "item" => [{ "1" => "3" }, { "2" => "4" }] }
+ hash_dst = { "item" => [{ "3" => "5" }] }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => [{"3" => "5"}, {"1" => "3"}, {"2" => "4"}]})
+ expect(hash_dst).to eq({ "item" => [{ "3" => "5" }, { "1" => "3" }, { "2" => "4" }] })
end
# Additions since import
it "should overwrite true with false when merging boolean values" do
- hash_src = {"valid" => false}
- hash_dst = {"valid" => true}
+ hash_src = { "valid" => false }
+ hash_dst = { "valid" => true }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"valid" => false})
+ expect(hash_dst).to eq({ "valid" => false })
end
it "should overwrite false with true when merging boolean values" do
- hash_src = {"valid" => true}
- hash_dst = {"valid" => false}
+ hash_src = { "valid" => true }
+ hash_dst = { "valid" => false }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"valid" => true})
+ expect(hash_dst).to eq({ "valid" => true })
end
it "should overwrite a string with an empty string when merging string values" do
- hash_src = {"item" => " "}
- hash_dst = {"item" => "orange"}
+ hash_src = { "item" => " " }
+ hash_dst = { "item" => "orange" }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => " "})
+ expect(hash_dst).to eq({ "item" => " " })
end
it "should overwrite an empty string with a string when merging string values" do
- hash_src = {"item" => "orange"}
- hash_dst = {"item" => " "}
+ hash_src = { "item" => "orange" }
+ hash_dst = { "item" => " " }
@dm.deep_merge!(hash_src, hash_dst)
- expect(hash_dst).to eq({"item" => "orange"})
+ expect(hash_dst).to eq({ "item" => "orange" })
end
end # deep_merge!
@@ -247,41 +247,41 @@ describe Chef::Mixin::DeepMerge do
describe "merge" do
it "should merge a hash into an empty hash" do
hash_dst = {}
- hash_src = {"id" => "2"}
+ hash_src = { "id" => "2" }
expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src)
end
it "should merge a nested hash into an empty hash" do
hash_dst = {}
- hash_src = {"region" => {"id" => ["227", "2"]}}
+ hash_src = { "region" => { "id" => ["227", "2"] } }
expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src)
end
it "should overwrite as string value when merging hashes" do
- hash_dst = {"name" => "value1"}
- hash_src = {"name" => "value"}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"name" => "value"})
+ hash_dst = { "name" => "value1" }
+ hash_src = { "name" => "value" }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "name" => "value" })
end
it "should merge arrays within hashes" do
- hash_dst = {"property" => ["2","4"]}
- hash_src = {"property" => ["1","3"]}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"property" => ["2","4","1","3"]})
+ hash_dst = { "property" => ["2", "4"] }
+ hash_src = { "property" => ["1", "3"] }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => ["2", "4", "1", "3"] })
end
it "should merge deeply nested hashes" do
- hash_dst = {"property" => {"values" => {"are" => "falling", "can" => "change"}}}
- hash_src = {"property" => {"values" => {"are" => "stable", "may" => "rise"}}}
- expect(@dm.merge(hash_dst, hash_src)).to eq({"property" => {"values" => {"are" => "stable", "can" => "change", "may" => "rise"}}})
+ hash_dst = { "property" => { "values" => { "are" => "falling", "can" => "change" } } }
+ hash_src = { "property" => { "values" => { "are" => "stable", "may" => "rise" } } }
+ expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => { "values" => { "are" => "stable", "can" => "change", "may" => "rise" } } })
end
it "should not modify the source or destination during the merge" do
- hash_dst = {"property" => ["1","2","3"]}
- hash_src = {"property" => ["4","5","6"]}
+ hash_dst = { "property" => ["1", "2", "3"] }
+ hash_src = { "property" => ["4", "5", "6"] }
ret = @dm.merge(hash_dst, hash_src)
- expect(hash_dst).to eq({"property" => ["1","2","3"]})
- expect(hash_src).to eq({"property" => ["4","5","6"]})
- expect(ret).to eq({"property" => ["1","2","3","4","5","6"]})
+ expect(hash_dst).to eq({ "property" => ["1", "2", "3"] })
+ expect(hash_src).to eq({ "property" => ["4", "5", "6"] })
+ expect(ret).to eq({ "property" => ["1", "2", "3", "4", "5", "6"] })
end
it "should not error merging un-dupable objects" do
@@ -292,8 +292,8 @@ describe Chef::Mixin::DeepMerge do
describe "hash-only merging" do
it "merges Hashes like normal deep merge" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => "1-a-merge-ee", "1_deep_b" => "1-deep-b-merge-ee"}, "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => "1-deep-b-merged-onto", "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => "1-a-merge-ee", "1_deep_b" => "1-deep-b-merge-ee" }, "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => "1-deep-b-merged-onto", "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -304,8 +304,8 @@ describe Chef::Mixin::DeepMerge do
end
it "replaces arrays rather than merging them" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => "1-a-merge-ee", "1_deep_b" => %w{A A A}}, "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => "1-a-merge-ee", "1_deep_b" => %w{A A A} }, "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -315,8 +315,8 @@ describe Chef::Mixin::DeepMerge do
end
it "replaces non-hash items with hashes when there's a conflict" do
- merge_ee_hash = {"top_level_a" => "top-level-a-mergee", "top_level_b" => "top-level-b-merge-ee"}
- merge_with_hash = {"top_level_a" => {"1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto"}, "top_level_b" => "top-level-b-merged-onto" }
+ merge_ee_hash = { "top_level_a" => "top-level-a-mergee", "top_level_b" => "top-level-b-merge-ee" }
+ merge_with_hash = { "top_level_a" => { "1_deep_b" => %w{B B B}, "1_deep_c" => "1-deep-c-merged-onto" }, "top_level_b" => "top-level-b-merged-onto" }
merged_result = @dm.hash_only_merge(merge_ee_hash, merge_with_hash)
@@ -326,16 +326,16 @@ describe Chef::Mixin::DeepMerge do
end
it "does not mutate deeply-nested original hashes by default" do
- merge_ee_hash = {"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" }}}}
- merge_with_hash = {"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" }}}}
+ merge_ee_hash = { "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" } } } }
+ merge_with_hash = { "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" } } } }
@dm.hash_only_merge(merge_ee_hash, merge_with_hash)
- expect(merge_ee_hash).to eq({"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" }}}})
- expect(merge_with_hash).to eq({"top_level_a" => {"1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" }}}})
+ expect(merge_ee_hash).to eq({ "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_a" => "foo" } } } })
+ expect(merge_with_hash).to eq({ "top_level_a" => { "1_deep_a" => { "2_deep_a" => { "3_deep_b" => "bar" } } } })
end
it "does not error merging un-dupable items" do
- merge_ee_hash = {"top_level_a" => 1, "top_level_b" => false}
- merge_with_hash = {"top_level_a" => 2, "top_level_b" => true }
+ merge_ee_hash = { "top_level_a" => 1, "top_level_b" => false }
+ merge_with_hash = { "top_level_a" => 2, "top_level_b" => true }
@dm.hash_only_merge(merge_ee_hash, merge_with_hash)
end
end
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index a08584baf9..259b89032e 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -23,18 +23,18 @@ class TinyClass
attr_reader :name
- def music(is_good=true)
+ def music(is_good = true)
is_good
end
end
describe Chef::Mixin::ParamsValidate do
before(:each) do
- @vo = TinyClass.new()
+ @vo = TinyClass.new()
end
it "should allow a hash and a hash as arguments to validate" do
- expect { @vo.validate({:one => "two"}, {}) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, {}) }.not_to raise_error
end
it "should raise an argument error if validate is called incorrectly" do
@@ -42,23 +42,23 @@ describe Chef::Mixin::ParamsValidate do
end
it "should require validation map keys to be symbols or strings" do
- expect { @vo.validate({:one => "two"}, { :one => true }) }.not_to raise_error
- expect { @vo.validate({:one => "two"}, { "one" => true }) }.not_to raise_error
- expect { @vo.validate({:one => "two"}, { Hash.new => true }) }.to raise_error(ArgumentError)
+ expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { "one" => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { Hash.new => true }) }.to raise_error(ArgumentError)
end
it "should allow options to be required with true" do
- expect { @vo.validate({:one => "two"}, { :one => true }) }.not_to raise_error
+ expect { @vo.validate({ :one => "two" }, { :one => true }) }.not_to raise_error
end
it "should allow options to be optional with false" do
- expect { @vo.validate({}, {:one => false})}.not_to raise_error
+ expect { @vo.validate({}, { :one => false }) }.not_to raise_error
end
it "should allow you to check what kind_of? thing an argument is with kind_of" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => String
@@ -69,7 +69,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => Array
@@ -82,7 +82,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify an argument is required with required" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:required => true
@@ -93,7 +93,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:two => "string"},
+ { :two => "string" },
{
:one => {
:required => true
@@ -104,7 +104,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:two => "string"},
+ { :two => "string" },
{
:one => {
:required => false
@@ -117,7 +117,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has a method with respond_to" do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => "validate"
@@ -128,7 +128,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => "monkey"
@@ -141,7 +141,7 @@ describe Chef::Mixin::ParamsValidate do
it "should allow you to specify whether an object has all the given methods with respond_to and an array" do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => ["validate", "music"]
@@ -152,7 +152,7 @@ describe Chef::Mixin::ParamsValidate do
expect {
@vo.validate(
- {:one => @vo},
+ { :one => @vo },
{
:one => {
:respond_to => ["monkey", "validate"]
@@ -293,14 +293,14 @@ describe Chef::Mixin::ParamsValidate do
it "should accept keys that are strings in the options" do
expect {
- @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ }})
+ @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } })
}.not_to raise_error
end
it "should allow an array to kind_of" do
expect {
@vo.validate(
- {:one => "string"},
+ { :one => "string" },
{
:one => {
:kind_of => [ String, Array ]
@@ -310,7 +310,7 @@ describe Chef::Mixin::ParamsValidate do
}.not_to raise_error
expect {
@vo.validate(
- {:one => ["string"]},
+ { :one => ["string"] },
{
:one => {
:kind_of => [ String, Array ]
@@ -320,7 +320,7 @@ describe Chef::Mixin::ParamsValidate do
}.not_to raise_error
expect {
@vo.validate(
- {:one => Hash.new},
+ { :one => Hash.new },
{
:one => {
:kind_of => [ String, Array ]
@@ -332,12 +332,12 @@ describe Chef::Mixin::ParamsValidate do
it "asserts that a value returns false from a predicate method" do
expect do
- @vo.validate({:not_blank => "should pass"},
- {:not_blank => {:cannot_be => [ :nil, :empty ]}})
+ @vo.validate({ :not_blank => "should pass" },
+ { :not_blank => { :cannot_be => [ :nil, :empty ] } })
end.not_to raise_error
expect do
- @vo.validate({:not_blank => ""},
- {:not_blank => {:cannot_be => [ :nil, :empty ]}})
+ @vo.validate({ :not_blank => "" },
+ { :not_blank => { :cannot_be => [ :nil, :empty ] } })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
@@ -367,31 +367,31 @@ describe Chef::Mixin::ParamsValidate do
it "should set and return @name, then return @name for foo when argument is nil" do
value = "meow"
- expect(@vo.set_or_return(:name, value, { }).object_id).to eq(value.object_id)
+ expect(@vo.set_or_return(:name, value, {}).object_id).to eq(value.object_id)
expect(@vo.set_or_return(:foo, nil, { :name_attribute => true }).object_id).to eq(value.object_id)
end
it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do
- value = Chef::DelayedEvaluator.new{ "test" }
- @vo.set_or_return(:test, value, {:kind_of => Numeric})
+ value = Chef::DelayedEvaluator.new { "test" }
+ @vo.set_or_return(:test, value, { :kind_of => Numeric })
end
it "should raise an error when delayed evaluated attribute is not valid" do
- value = Chef::DelayedEvaluator.new{ "test" }
- @vo.set_or_return(:test, value, {:kind_of => Numeric})
+ value = Chef::DelayedEvaluator.new { "test" }
+ @vo.set_or_return(:test, value, { :kind_of => Numeric })
expect do
- @vo.set_or_return(:test, nil, {:kind_of => Numeric})
+ @vo.set_or_return(:test, nil, { :kind_of => Numeric })
end.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "should create DelayedEvaluator instance when #lazy is used" do
- @vo.set_or_return(:delayed, @vo.lazy{ "test" }, {})
+ @vo.set_or_return(:delayed, @vo.lazy { "test" }, {})
expect(@vo.instance_variable_get(:@delayed)).to be_a(Chef::DelayedEvaluator)
end
it "should execute block on each call when DelayedEvaluator" do
value = "fubar"
- @vo.set_or_return(:test, @vo.lazy{ value }, {})
+ @vo.set_or_return(:test, @vo.lazy { value }, {})
expect(@vo.set_or_return(:test, nil, {})).to eq("fubar")
value = "foobar"
expect(@vo.set_or_return(:test, nil, {})).to eq("foobar")
@@ -400,7 +400,7 @@ describe Chef::Mixin::ParamsValidate do
end
it "should not evaluate non DelayedEvaluator instances" do
- value = lambda{ "test" }
+ value = lambda { "test" }
@vo.set_or_return(:test, value, {})
expect(@vo.set_or_return(:test, nil, {}).object_id).to eq(value.object_id)
expect(@vo.set_or_return(:test, nil, {})).to be_a(Proc)
diff --git a/spec/unit/mixin/path_sanity_spec.rb b/spec/unit/mixin/path_sanity_spec.rb
index 2679780c76..e410f034d5 100644
--- a/spec/unit/mixin/path_sanity_spec.rb
+++ b/spec/unit/mixin/path_sanity_spec.rb
@@ -39,25 +39,25 @@ describe Chef::Mixin::PathSanity do
end
it "adds all useful PATHs even if environment is an empty hash" do
- env={}
+ env = {}
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
it "adds all useful PATHs that are not yet in PATH to PATH" do
- env = {"PATH" => ""}
+ env = { "PATH" => "" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
it "does not re-add paths that already exist in PATH" do
- env = {"PATH" => "/usr/bin:/sbin:/bin"}
+ env = { "PATH" => "/usr/bin:/sbin:/bin" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("/usr/bin:/sbin:/bin:#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin")
end
it "adds the current executing Ruby's bindir and Gem bindir to the PATH" do
- env = {"PATH" => ""}
+ env = { "PATH" => "" }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{@ruby_bindir}:#{@gem_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
@@ -67,7 +67,7 @@ describe Chef::Mixin::PathSanity do
gem_bindir = "/yo/gabba/gabba"
allow(Gem).to receive(:bindir).and_return(gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
- env = {"PATH" => gem_bindir}
+ env = { "PATH" => gem_bindir }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("/yo/gabba/gabba:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
end
@@ -78,7 +78,7 @@ describe Chef::Mixin::PathSanity do
allow(Gem).to receive(:bindir).and_return(gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
allow(ChefConfig).to receive(:windows?).and_return(true)
- env = {"PATH" => 'C:\Windows\system32;C:\mr\softie'}
+ env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("C:\\Windows\\system32;C:\\mr\\softie;#{ruby_bindir};#{gem_bindir}")
end
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index 8e2e4e2b45..b586be7fdc 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -21,9 +21,9 @@ require "chef/mixin/powershell_out"
describe Chef::Mixin::PowershellOut do
let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } }
subject(:object) { shell_out_class.new }
- let(:architecture) { "something" }
+ let(:architecture) { "something" }
let(:flags) {
- "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None"
+ "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None"
}
describe "#powershell_out" do
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index f7b4fcd723..7f2ecb94e2 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -55,17 +55,17 @@ describe Chef::Mixin::PowershellTypeCoercions do
end
it "translates all members of a hash and wrap them in @{} separated by ;" do
- expect(test_class.translate_type({"a" => 1, "b" => 1.2, "c" => false, "d" => true
+ expect(test_class.translate_type({ "a" => 1, "b" => 1.2, "c" => false, "d" => true
})).to eq("@{a=1;b=1.2;c=$false;d=$true}")
end
it "translates all members of an array and them by a ," do
expect(test_class.translate_type([true, false])).to eq("@($true,$false)")
end
-
+
it "translates a Chef::Node::ImmutableMash like a hash" do
- test_mash = Chef::Node::ImmutableMash.new({"a" => 1, "b" => 1.2,
- "c" => false, "d" => true})
+ test_mash = Chef::Node::ImmutableMash.new({ "a" => 1, "b" => 1.2,
+ "c" => false, "d" => true })
expect(test_class.translate_type(test_mash)).to eq("@{a=1;b=1.2;c=$false;d=$true}")
end
diff --git a/spec/unit/mixin/proxified_socket_spec.rb b/spec/unit/mixin/proxified_socket_spec.rb
index d8cc762210..1d752bb600 100644
--- a/spec/unit/mixin/proxified_socket_spec.rb
+++ b/spec/unit/mixin/proxified_socket_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Mixin::ProxifiedSocket do
let(:host) { "host" }
let(:port) { 7979 }
let(:test_instance) { TestProxifiedSocket.new }
- let(:socket_double) { instance_double(TCPSocket)}
+ let(:socket_double) { instance_double(TCPSocket) }
let(:proxifier_double) { instance_double(Proxifier::Proxy) }
let(:http_uri) { "http://somehost:1" }
let(:https_uri) { "https://somehost:1" }
diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb
index 50bfe84b27..6f50ce853f 100644
--- a/spec/unit/mixin/securable_spec.rb
+++ b/spec/unit/mixin/securable_spec.rb
@@ -253,7 +253,7 @@ describe Chef::Mixin::Securable do
it "should accept a principal as a string or an array" do
expect { @securable.rights :read, "The Dude" }.not_to raise_error
- expect { @securable.rights :read, ["The Dude","Donny"] }.not_to raise_error
+ expect { @securable.rights :read, ["The Dude", "Donny"] }.not_to raise_error
expect { @securable.rights :read, 3 }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 6d7e12af4b..12336b1dbb 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Mixin::ShellOut do
let(:cmd) { "echo '#{rand(1000)}'" }
let(:output) { StringIO.new }
- let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
+ let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) }
context "without options" do
@@ -171,7 +171,7 @@ describe Chef::Mixin::ShellOut do
end
it "should not change env when language options are set to non-nil" do
- options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8" }}
+ options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out(cmd, options)
end
@@ -266,7 +266,7 @@ describe Chef::Mixin::ShellOut do
end
it "should not change env when set to non-nil" do
- options = { :env => { "LC_ALL" => "en_US.UTF-8"}}
+ options = { :env => { "LC_ALL" => "en_US.UTF-8" } }
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
shell_out_obj.shell_out_with_systems_locale(cmd, options)
end
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 41e2174eb0..48150f7198 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -172,7 +172,7 @@ describe Chef::Mixin::Template, "render_template" do
expect(output).to eq("before {super secret is } after")
output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb' %>} after")
- expect(output).to eq("before {super secret is } after")
+ expect(output).to eq("before {super secret is } after")
end
it "should render nested partials" do
@@ -199,10 +199,13 @@ describe Chef::Mixin::Template, "render_template" do
mod = Module.new do
def render
end
+
def node
end
+
def render_template
end
+
def render_template_from_string
end
end
@@ -225,7 +228,7 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should raise an error if an attempt is made to access node but it is nil" do
- expect {@context.render_template_from_string("<%= node %>") {|r| r}}.to raise_error(Chef::Mixin::Template::TemplateError)
+ expect { @context.render_template_from_string("<%= node %>") { |r| r } }.to raise_error(Chef::Mixin::Template::TemplateError)
end
describe "the raised TemplateError" do
diff --git a/spec/unit/mixin/uris_spec.rb b/spec/unit/mixin/uris_spec.rb
index 13012617bc..9005edd7b4 100644
--- a/spec/unit/mixin/uris_spec.rb
+++ b/spec/unit/mixin/uris_spec.rb
@@ -46,7 +46,7 @@ describe Chef::Mixin::Uris do
describe "#as_uri" do
it "parses a file scheme uri with spaces" do
- expect{ uris.as_uri("file:///c:/foo bar.txt") }.not_to raise_exception
+ expect { uris.as_uri("file:///c:/foo bar.txt") }.not_to raise_exception
end
it "returns a URI object" do
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 25064678fa..aaf9fa4b2b 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -16,12 +16,9 @@
# limitations under the License.
#
-
require "spec_helper"
require "chef/mixin/windows_architecture_helper"
-
-
describe Chef::Mixin::WindowsArchitectureHelper do
include Chef::Mixin::WindowsArchitectureHelper
@@ -34,25 +31,25 @@ describe Chef::Mixin::WindowsArchitectureHelper do
end
it "returns true when valid architectures are passed to valid_windows_architecture?" do
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
expect(valid_windows_architecture?(architecture)).to eq(true)
end
end
it "returns false when invalid architectures are passed to valid_windows_architecture?" do
- @invalid_architectures.each do | architecture |
+ @invalid_architectures.each do |architecture|
expect(valid_windows_architecture?(architecture)).to eq(false)
end
end
it "does not raise an exception when a valid architecture is passed to assert_valid_windows_architecture!" do
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
assert_valid_windows_architecture!(architecture)
end
end
it "raises an error if an invalid architecture is passed to assert_valid_windows_architecture!" do
- @invalid_architectures.each do | architecture |
+ @invalid_architectures.each do |architecture|
begin
expect(assert_valid_windows_architecture!(architecture)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
rescue Chef::Exceptions::Win32ArchitectureIncorrect
@@ -61,26 +58,26 @@ describe Chef::Mixin::WindowsArchitectureHelper do
end
it "returns true only for supported desired architecture passed to node_supports_windows_architecture" do
- with_node_architecture_combinations do | node, desired_arch |
- expect(node_supports_windows_architecture?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64 || desired_arch == :i386 )
- expect(node_supports_windows_architecture?(node, desired_arch)).to be false if (node_windows_architecture(node) == :i386 && desired_arch == :x86_64 )
+ with_node_architecture_combinations do |node, desired_arch|
+ expect(node_supports_windows_architecture?(node, desired_arch)).to be true if (node_windows_architecture(node) == :x86_64 || desired_arch == :i386 )
+ expect(node_supports_windows_architecture?(node, desired_arch)).to be false if (node_windows_architecture(node) == :i386 && desired_arch == :x86_64 )
end
end
it "returns true only when forced_32bit_override_required? has 64-bit node architecture and 32-bit desired architecture" do
- with_node_architecture_combinations do | node, desired_arch |
+ with_node_architecture_combinations do |node, desired_arch|
expect(forced_32bit_override_required?(node, desired_arch)).to be true if ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386) && !is_i386_process_on_x86_64_windows?)
expect(forced_32bit_override_required?(node, desired_arch)).to be false if ! ((node_windows_architecture(node) == :x86_64) && (desired_arch == :i386))
end
end
def with_node_architecture_combinations
- @valid_architectures.each do | node_architecture |
+ @valid_architectures.each do |node_architecture|
new_node = Chef::Node.new
new_node.default["kernel"] = Hash.new
new_node.default["kernel"][:machine] = node_architecture.to_s
- @valid_architectures.each do | architecture |
+ @valid_architectures.each do |architecture|
yield new_node, architecture if block_given?
end
end