diff options
Diffstat (limited to 'spec/unit/knife/bootstrap')
-rw-r--r-- | spec/unit/knife/bootstrap/chef_vault_handler_spec.rb | 30 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap/client_builder_spec.rb | 18 |
2 files changed, 24 insertions, 24 deletions
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb index 29eeea62f7..4d36208be0 100644 --- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb @@ -25,12 +25,12 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do let(:stdin) { StringIO.new } let(:ui) { Chef::Knife::UI.new(stdout, stderr, stdin, {}) } - let(:knife_config) { {} } + let(:config) { {} } let(:client) { Chef::ApiClient.new } let(:chef_vault_handler) do - chef_vault_handler = Chef::Knife::Bootstrap::ChefVaultHandler.new(knife_config: knife_config, ui: ui) + chef_vault_handler = Chef::Knife::Bootstrap::ChefVaultHandler.new(config: config, ui: ui) chef_vault_handler end @@ -55,28 +55,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do expect(bootstrap_vault_item).to receive(:save).at_least(:once) end - context "from knife_config[:bootstrap_vault_item]" do + context "from config[:bootstrap_vault_item]" do it "sets a single item as a scalar" do - knife_config[:bootstrap_vault_item] = { "vault" => "item1" } + config[:bootstrap_vault_item] = { "vault" => "item1" } expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets a single item as an array" do - knife_config[:bootstrap_vault_item] = { "vault" => [ "item1" ] } + config[:bootstrap_vault_item] = { "vault" => [ "item1" ] } expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two items as an array" do - knife_config[:bootstrap_vault_item] = { "vault" => %w{item1 item2} } + config[:bootstrap_vault_item] = { "vault" => %w{item1 item2} } expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two vaults from different hash keys" do - knife_config[:bootstrap_vault_item] = { "vault" => %w{item1 item2}, "vault2" => [ "item3" ] } + config[:bootstrap_vault_item] = { "vault" => %w{item1 item2}, "vault2" => [ "item3" ] } expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item) @@ -84,28 +84,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do end end - context "from knife_config[:bootstrap_vault_json]" do + context "from config[:bootstrap_vault_json]" do it "sets a single item as a scalar" do - knife_config[:bootstrap_vault_json] = '{ "vault": "item1" }' + config[:bootstrap_vault_json] = '{ "vault": "item1" }' expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets a single item as an array" do - knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1" ] }' + config[:bootstrap_vault_json] = '{ "vault": [ "item1" ] }' expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two items as an array" do - knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ] }' + config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ] }' expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two vaults from different hash keys" do - knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }' + config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }' expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item) @@ -113,12 +113,12 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do end end - context "from knife_config[:bootstrap_vault_file]" do + context "from config[:bootstrap_vault_file]" do def setup_file_contents(json) stringio = StringIO.new(json) - knife_config[:bootstrap_vault_file] = "/foo/bar/baz" - expect(File).to receive(:read).with(knife_config[:bootstrap_vault_file]).and_return(stringio) + config[:bootstrap_vault_file] = "/foo/bar/baz" + expect(File).to receive(:read).with(config[:bootstrap_vault_file]).and_return(stringio) end it "sets a single item as a scalar" do diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb index 87720091cd..10edd13882 100644 --- a/spec/unit/knife/bootstrap/client_builder_spec.rb +++ b/spec/unit/knife/bootstrap/client_builder_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do let(:stdin) { StringIO.new } let(:ui) { Chef::Knife::UI.new(stdout, stderr, stdin, {}) } - let(:knife_config) { {} } + let(:config) { {} } let(:chef_config) { {} } @@ -34,7 +34,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do let(:rest) { double("Chef::ServerAPI") } let(:client_builder) do - client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(knife_config: knife_config, chef_config: chef_config, ui: ui) + client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(config: config, chef_config: chef_config, ui: ui) allow(client_builder).to receive(:rest).and_return(rest) allow(client_builder).to receive(:node_name).and_return(node_name) client_builder @@ -160,7 +160,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do it "adds tags to the node when given" do tag_receiver = [] - knife_config[:tags] = %w{foo bar} + config[:tags] = %w{foo bar} allow(node).to receive(:run_list).with([]) allow(node).to receive(:tags).and_return(tag_receiver) client_builder.run @@ -168,34 +168,34 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end it "builds a node when the run_list is a string" do - knife_config[:run_list] = "role[base],role[app]" + config[:run_list] = "role[base],role[app]" expect(node).to receive(:run_list).with(["role[base]", "role[app]"]) client_builder.run end it "builds a node when the run_list is an Array" do - knife_config[:run_list] = ["role[base]", "role[app]"] + config[:run_list] = ["role[base]", "role[app]"] expect(node).to receive(:run_list).with(["role[base]", "role[app]"]) client_builder.run end it "builds a node with first_boot_attributes if they're given" do - knife_config[:first_boot_attributes] = { baz: :quux } + config[:first_boot_attributes] = { baz: :quux } expect(node).to receive(:normal_attrs=).with({ baz: :quux }) expect(node).to receive(:run_list).with([]) client_builder.run end it "builds a node with an environment if its given" do - knife_config[:environment] = "production" + config[:environment] = "production" expect(node).to receive(:environment).with("production") expect(node).to receive(:run_list).with([]) client_builder.run end it "builds a node with policy_name and policy_group when given" do - knife_config[:policy_name] = "my-app" - knife_config[:policy_group] = "staging" + config[:policy_name] = "my-app" + config[:policy_group] = "staging" expect(node).to receive(:run_list).with([]) expect(node).to receive(:policy_name=).with("my-app") |