diff options
Diffstat (limited to 'spec/unit/mixin')
-rw-r--r-- | spec/unit/mixin/deep_merge_spec.rb | 60 | ||||
-rw-r--r-- | spec/unit/mixin/params_validate_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/properties_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/mixin/template_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/windows_architecture_helper_spec.rb | 6 |
5 files changed, 44 insertions, 44 deletions
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb index 2850193eb6..6a9ea55d2e 100644 --- a/spec/unit/mixin/deep_merge_spec.rb +++ b/spec/unit/mixin/deep_merge_spec.rb @@ -41,7 +41,7 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests merging an hash w/array into blank hash" do - hash_src = { "region" => { "id" => ["227", "2"] } } + hash_src = { "region" => { "id" => %w(227 2) } } hash_dst = {} @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq(hash_src) @@ -49,16 +49,16 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do it "tests merge from empty hash" do hash_src = {} - hash_dst = { "property" => ["2", "4"] } + hash_dst = { "property" => %w(2 4) } @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({ "property" => ["2", "4"] }) + expect(hash_dst).to eq({ "property" => %w(2 4) }) end it "tests merge to empty hash" do - hash_src = { "property" => ["2", "4"] } + hash_src = { "property" => %w(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" => %w(2 4) }) end it "tests simple string overwrite" do @@ -76,36 +76,36 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests hashes holding array" do - hash_src = { "property" => ["1", "3"] } - hash_dst = { "property" => ["2", "4"] } + hash_src = { "property" => %w(1 3) } + hash_dst = { "property" => %w(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" => %w(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" => %w(1 2), "bathroom_count" => ["1", "4+"] } } + hash_dst = { "property" => { "bedroom_count" => %w(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" => %w(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_src = { "property" => { "bedroom_count" => %w(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" => %w(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_dst = { "property" => { "bedroom_count" => %w(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+"] } }) 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_dst = { "property" => { "bedroom_count" => %w(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+"] } }) end @@ -142,21 +142,21 @@ describe Chef::Mixin::DeepMerge, "deep_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"] } } @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" => %w(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"] } } @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" => %w(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"] } } @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" => %w(2 1) } }) end it "tests 3 hash layers holding arrays of int, but source is empty" do @@ -174,10 +174,10 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests hash holding arrays of arrays" do - hash_src = { ["1", "2", "3"] => ["1", "2"] } - hash_dst = { ["4", "5"] => ["3"] } + hash_src = { %w(1 2 3) => %w(1 2) } + hash_dst = { %w(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({ %w(1 2 3) => %w(1 2), %w(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 @@ -253,7 +253,7 @@ describe Chef::Mixin::DeepMerge do it "should merge a nested hash into an empty hash" do hash_dst = {} - hash_src = { "region" => { "id" => ["227", "2"] } } + hash_src = { "region" => { "id" => %w(227 2) } } expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src) end @@ -264,9 +264,9 @@ describe Chef::Mixin::DeepMerge do 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" => %w(2 4) } + hash_src = { "property" => %w(1 3) } + expect(@dm.merge(hash_dst, hash_src)).to eq({ "property" => %w(2 4 1 3) }) end it "should merge deeply nested hashes" do @@ -276,12 +276,12 @@ describe Chef::Mixin::DeepMerge do 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" => %w(1 2 3) } + hash_src = { "property" => %w(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" => %w(1 2 3) }) + expect(hash_src).to eq({ "property" => %w(4 5 6) }) + expect(ret).to eq({ "property" => %w(1 2 3 4 5 6) }) end it "should not error merging un-dupable objects" do diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 259b89032e..ae0cdcc803 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -144,7 +144,7 @@ describe Chef::Mixin::ParamsValidate do { :one => @vo }, { :one => { - :respond_to => ["validate", "music"] + :respond_to => %w(validate music) } }, ) @@ -155,7 +155,7 @@ describe Chef::Mixin::ParamsValidate do { :one => @vo }, { :one => { - :respond_to => ["monkey", "validate"] + :respond_to => %w(monkey validate) } }, ) diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb index 00e339a221..95babb2fe7 100644 --- a/spec/unit/mixin/properties_spec.rb +++ b/spec/unit/mixin/properties_spec.rb @@ -9,8 +9,8 @@ module ChefMixinPropertiesSpec class A include Chef::Mixin::Properties property :a, "a", default: "a" - property :ab, ["a", "b"], default: "a" - property :ac, ["a", "c"], default: "a" + property :ab, %w(a b), default: "a" + property :ac, %w(a c), default: "a" end context "and a module B with properties b, ab and bc" do @@ -18,7 +18,7 @@ module ChefMixinPropertiesSpec include Chef::Mixin::Properties property :b, "b", default: "b" property :ab, default: "b" - property :bc, ["b", "c"], default: "c" + property :bc, %w(b c), default: "c" end context "and a derived class C < A with properties c, ac and bc" do @@ -32,22 +32,22 @@ module ChefMixinPropertiesSpec it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do expect(A.properties.keys).to eq [ :a, :ab, :ac ] expect(A.properties[:a].validation_options[:is]).to eq "a" - expect(A.properties[:ab].validation_options[:is]).to eq [ "a", "b" ] - expect(A.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] + expect(A.properties[:ab].validation_options[:is]).to eq %w(a b) + expect(A.properties[:ac].validation_options[:is]).to eq %w(a c) end it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do expect(B.properties.keys).to eq [ :b, :ab, :bc ] expect(B.properties[:b].validation_options[:is]).to eq "b" expect(B.properties[:ab].validation_options[:is]).to be_nil - expect(B.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] + expect(B.properties[:bc].validation_options[:is]).to eq %w(b c) end it "C.properties has a, b, c, ac and bc with merged types" do expect(C.properties.keys).to eq [ :a, :ab, :ac, :b, :bc, :c ] expect(C.properties[:a].validation_options[:is]).to eq "a" expect(C.properties[:b].validation_options[:is]).to eq "b" expect(C.properties[:c].validation_options[:is]).to eq "c" - expect(C.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] - expect(C.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] + expect(C.properties[:ac].validation_options[:is]).to eq %w(a c) + expect(C.properties[:bc].validation_options[:is]).to eq %w(b c) end it "C.properties has ab with a non-merged type (from B)" do expect(C.properties[:ab].validation_options[:is]).to be_nil diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb index 48150f7198..1021cbc5f3 100644 --- a/spec/unit/mixin/template_spec.rb +++ b/spec/unit/mixin/template_spec.rb @@ -209,7 +209,7 @@ describe Chef::Mixin::Template, "render_template" do def render_template_from_string end end - ["node", "render", "render_template", "render_template_from_string"].each do |method_name| + %w(node render render_template render_template_from_string).each do |method_name| expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/) end @template_context._extend_modules([mod]) diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index aaf9fa4b2b..59b03b4726 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -59,14 +59,14 @@ describe Chef::Mixin::WindowsArchitectureHelper do 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 ) + 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| - 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 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 |