summaryrefslogtreecommitdiff
path: root/spec/unit/knife
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/knife')
-rw-r--r--spec/unit/knife/bootstrap/chef_vault_handler_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap_spec.rb14
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb16
-rw-r--r--spec/unit/knife/client_edit_spec.rb4
-rw-r--r--spec/unit/knife/configure_client_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb8
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb11
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb9
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb6
-rw-r--r--spec/unit/knife/core/ui_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb5
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb5
-rw-r--r--spec/unit/knife/key_create_spec.rb28
-rw-r--r--spec/unit/knife/key_delete_spec.rb4
-rw-r--r--spec/unit/knife/key_edit_spec.rb32
-rw-r--r--spec/unit/knife/key_list_spec.rb12
-rw-r--r--spec/unit/knife/key_show_spec.rb8
-rw-r--r--spec/unit/knife/status_spec.rb5
-rw-r--r--spec/unit/knife/user_create_spec.rb8
20 files changed, 99 insertions, 92 deletions
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
index 734b27216d..d822fe8f98 100644
--- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
+++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
@@ -29,10 +29,10 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do
let(:client) { Chef::ApiClient.new }
- let(:chef_vault_handler) {
+ let(:chef_vault_handler) do
chef_vault_handler = Chef::Knife::Bootstrap::ChefVaultHandler.new(knife_config: knife_config, ui: ui)
chef_vault_handler
- }
+ end
context "when there's no vault option" do
it "should report its not doing anything" do
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 491d0ca754..97ba0fc48e 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -33,12 +33,12 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
let(:rest) { double("Chef::ServerAPI") }
- let(:client_builder) {
+ let(:client_builder) do
client_builder = Chef::Knife::Bootstrap::ClientBuilder.new(knife_config: knife_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
- }
+ end
context "#sanity_check!" do
let(:response_404) { OpenStruct.new(:code => "404") }
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 5f1ba9f781..9f944b82d9 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -236,11 +236,11 @@ describe Chef::Knife::Bootstrap do
end
context "with bootstrap_attribute options" do
- let(:jsonfile) {
+ let(:jsonfile) do
file = Tempfile.new (["node", ".json"])
File.open(file.path, "w") { |f| f.puts '{"foo":{"bar":"baz"}}' }
file
- }
+ end
it "should have foo => {bar => baz} in the first_boot from cli" do
knife.parse_options(["-j", '{"foo":{"bar":"baz"}}'])
@@ -478,8 +478,9 @@ describe Chef::Knife::Bootstrap do
end
context "when client_d_dir is set" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_00")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_00")) end
it "creates /etc/chef/client.d" do
expect(rendered_template).to match("mkdir -p /etc/chef/client\.d")
@@ -497,8 +498,9 @@ describe Chef::Knife::Bootstrap do
end
context "a nested directory structure" do
- let(:client_d_dir) { Chef::Util::PathHelper.cleanpath(
- File.join(File.dirname(__FILE__), "../../data/client.d_01")) }
+ let(:client_d_dir) do
+ Chef::Util::PathHelper.cleanpath(
+ File.join(File.dirname(__FILE__), "../../data/client.d_01")) end
it "creates a file foo/bar.rb" do
expect(rendered_template).to match("cat > /etc/chef/client.d/foo/bar.rb <<'EOP'")
expect(rendered_template).to match("1 / 0")
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index a9b18c9086..994f4d33a4 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Knife::ClientBulkDelete do
let(:stderr_io) { StringIO.new }
let(:stderr) { stderr_io.string }
- let(:knife) {
+ let(:knife) do
k = Chef::Knife::ClientBulkDelete.new
k.name_args = name_args
k.config = option_args
@@ -33,7 +33,7 @@ describe Chef::Knife::ClientBulkDelete do
allow(k.ui).to receive(:confirm).and_return(knife_confirm)
allow(k.ui).to receive(:confirm_without_exit).and_return(knife_confirm)
k
- }
+ end
let(:name_args) { [ "." ] }
let(:option_args) { {} }
@@ -41,7 +41,7 @@ describe Chef::Knife::ClientBulkDelete do
let(:knife_confirm) { true }
let(:nonvalidator_client_names) { %w{tim dan stephen} }
- let(:nonvalidator_clients) {
+ let(:nonvalidator_clients) do
clients = Hash.new
nonvalidator_client_names.each do |client_name|
@@ -52,10 +52,10 @@ describe Chef::Knife::ClientBulkDelete do
end
clients
- }
+ end
let(:validator_client_names) { %w{myorg-validator} }
- let(:validator_clients) {
+ let(:validator_clients) do
clients = Hash.new
validator_client_names.each do |validator_client_name|
@@ -67,12 +67,12 @@ describe Chef::Knife::ClientBulkDelete do
end
clients
- }
+ end
let(:client_names) { nonvalidator_client_names + validator_client_names }
- let(:clients) {
+ let(:clients) do
nonvalidator_clients.merge(validator_clients)
- }
+ end
before(:each) do
allow(Chef::ApiClientV1).to receive(:list).and_return(clients)
diff --git a/spec/unit/knife/client_edit_spec.rb b/spec/unit/knife/client_edit_spec.rb
index 584a94014c..e7c9030883 100644
--- a/spec/unit/knife/client_edit_spec.rb
+++ b/spec/unit/knife/client_edit_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Knife::ClientEdit do
end
describe "run" do
- let(:data) {
+ let(:data) do
{
"name" => "adam",
"validator" => false,
@@ -35,7 +35,7 @@ describe Chef::Knife::ClientEdit do
"chef_type" => "client",
"create_key" => true,
}
- }
+ end
it "should edit the client" do
allow(Chef::ApiClientV1).to receive(:load).with("adam").and_return(data)
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index 192da862d7..3ecb89f827 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -33,9 +33,9 @@ describe Chef::Knife::ConfigureClient do
it "should print usage and exit when a directory is not provided" do
expect(@knife).to receive(:show_usage)
expect(@knife.ui).to receive(:fatal).with(/must provide the directory/)
- expect {
+ expect do
@knife.run
- }.to raise_error SystemExit
+ end.to raise_error SystemExit
end
describe "when specifing a directory" do
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index 0e3fccfa7e..4b405d0842 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -128,9 +128,9 @@ describe Chef::Knife::CookbookMetadata do
it "should print an error and exit when an #{description} syntax exception is encountered" do
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:new).and_raise(exception)
- expect {
+ expect do
@knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb")
- }.to raise_error(SystemExit)
+ end.to raise_error(SystemExit)
expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im
expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.rb/im
expect(@stderr.string).to match /#{description} blah/im
@@ -166,9 +166,9 @@ describe Chef::Knife::CookbookMetadata do
and_return(@json_data)
exception = klass.new("#{description} blah")
allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception)
- expect {
+ expect do
@knife.validate_metadata_json(@cookbook_dir, "foobar")
- }.to raise_error(SystemExit)
+ end.to raise_error(SystemExit)
expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im
expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.json/im
expect(@stderr.string).to match /#{description} blah/im
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index 1549245ea3..d93af10761 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -24,16 +24,17 @@ describe Chef::Knife::CookbookSiteInstall do
let(:stderr) { StringIO.new }
let(:downloader) { Hash.new }
let(:archive) { double(Mixlib::Archive, extract: true) }
- let(:repo) { double(:sanity_check => true, :reset_to_default_state => true,
- :prepare_to_import => true, :finalize_updates_to => true,
- :merge_updates_from => true) }
- let(:install_path) {
+ let(:repo) do
+ double(:sanity_check => true, :reset_to_default_state => true,
+ :prepare_to_import => true, :finalize_updates_to => true,
+ :merge_updates_from => true) end
+ let(:install_path) do
if Chef::Platform.windows?
"C:/tmp/chef"
else
"/var/tmp/chef"
end
- }
+ end
before(:each) do
require "chef/knife/core/cookbook_scm_repo"
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 081f9deae5..53bd81f4f7 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
allow(ChefConfig).to receive(:windows?) { false }
end
- let(:plugin_manifest) {
+ let(:plugin_manifest) do
{
"_autogenerated_command_paths" => {
"plugins_paths" => {
@@ -39,11 +39,12 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
},
},
}
- }
+ end
- let(:loader) { Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
+ let(:loader) do
+ Chef::Knife::SubcommandLoader::HashedCommandLoader.new(
File.join(CHEF_SPEC_DATA, "knife-site-subcommands"),
- plugin_manifest)}
+ plugin_manifest) end
describe "#list_commands" do
before do
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index 19af419632..ce169a77dd 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Knife::NodeEditor do
subject { described_class.new(node, ui, config) }
- describe '#view' do
+ describe "#view" do
it "returns a Hash with only the name, chef_environment, normal, " +
"policy_name, policy_group, and run_list properties" do
expected = node_data.select do |key,|
@@ -61,7 +61,7 @@ describe Chef::Knife::NodeEditor do
end
end
- describe '#apply_updates' do
+ describe "#apply_updates" do
context "when the node name is changed" do
before(:each) do
allow(ui).to receive(:warn)
@@ -143,7 +143,7 @@ describe Chef::Knife::NodeEditor do
end
end
- describe '#updated?' do
+ describe "#updated?" do
context "before the node has been edited" do
it "returns false" do
expect(subject.updated?).to be false
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 0b9547fc1f..9f525f22f0 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -500,9 +500,9 @@ EOM
shared_examples_for "confirm with negative answer" do
it "confirm should exit 3" do
- expect {
+ expect do
run_confirm
- }.to raise_error(SystemExit) { |e| expect(e.status).to eq(3) }
+ end.to raise_error(SystemExit) { |e| expect(e.status).to eq(3) }
end
it "confirm_without_exit should return false" do
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index bf6bd82a68..3bea392ae2 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -72,11 +72,12 @@ describe Chef::Knife::DataBagFromFile do
let(:loader) { double("Knife::Core::ObjectLoader") }
let(:data_bags_path) { "data_bags" }
- let(:plain_data) { {
+ let(:plain_data) do
+ {
"id" => "item_name",
"greeting" => "hello",
"nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } },
- } }
+ } end
let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) }
let(:rest) { double("Chef::ServerAPI") }
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 0672b8bb33..ece7f5bf78 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -45,8 +45,9 @@ describe Chef::Knife::DataBagShow do
let(:bag_name) { "sudoing_admins" }
let(:item_name) { "ME" }
- let(:data_bag_contents) { { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
- "qux" => "http://localhost:4000/data/bag_o_data/qux" } }
+ let(:data_bag_contents) do
+ { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz",
+ "qux" => "http://localhost:4000/data/bag_o_data/qux" } end
let(:enc_hash) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(data_bag_contents, secret) }
let(:data_bag) { Chef::DataBagItem.from_hash(data_bag_contents) }
let(:data_bag_with_encoded_hash) { Chef::DataBagItem.from_hash(enc_hash) }
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 146b6a904b..5b00c6ea31 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -73,7 +73,7 @@ describe "key create commands that inherit knife" do
end
describe Chef::Knife::KeyCreate do
- let(:public_key) {
+ let(:public_key) do
"-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
@@ -83,15 +83,15 @@ IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
- }
+ end
let(:config) { Hash.new }
let(:actor) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key create run command" do
- let(:key_create_object) {
+ let(:key_create_object) do
described_class.new(actor, actor_field_name, ui, config)
- }
+ end
context "when public_key and key_name weren't passed" do
it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do
@@ -100,11 +100,11 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when the command is run" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
}
- }
+ end
before do
allow(File).to receive(:read).and_return(public_key)
@@ -120,14 +120,14 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
context "when a valid hash is passed" do
let(:key_name) { "charmander-key" }
let(:valid_expiration_date) { "2020-12-24T21:00:00Z" }
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"expiration_date" => valid_expiration_date,
"key_name" => key_name,
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
key_create_object.config[:expiration_Date] = valid_expiration_date,
@@ -141,12 +141,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
end
@@ -158,13 +158,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end # when public_key is passed
context "when public_key isn't passed and key_name is" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => "charmander-key",
"create_key" => true,
}
- }
+ end
before do
key_create_object.config[:key_name] = "charmander-key"
end
@@ -176,13 +176,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when the server returns a private key" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"private_key" => "super_private",
}
- }
+ end
before do
key_create_object.config[:public_key] = "public_key_path"
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index 3da5a9762a..0176f3c71e 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -80,9 +80,9 @@ describe Chef::Knife::KeyDelete do
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key delete run command" do
- let(:key_delete_object) {
+ let(:key_delete_object) do
described_class.new(keyname, actor, actor_field_name, ui)
- }
+ end
before do
allow_any_instance_of(Chef::Key).to receive(:destroy)
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index 9195e97135..244d8bdcc7 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -75,7 +75,7 @@ describe "key edit commands that inherit knife" do
end
describe Chef::Knife::KeyEdit do
- let(:public_key) {
+ let(:public_key) do
"-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvPo+oNPB7uuNkws0fC02
KxSwdyqPLu0fhI1pOweNKAZeEIiEz2PkybathHWy8snSXGNxsITkf3eyvIIKa8OZ
@@ -85,23 +85,23 @@ IjSmiN/ihHtlhV/VSnBJ5PzT/lRknlrJ4kACoz7Pq9jv+aAx5ft/xE9yDa2DYs0q
Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
0wIDAQAB
-----END PUBLIC KEY-----"
- }
+ end
let(:config) { Hash.new }
let(:actor) { "charmander" }
let(:keyname) { "charmander-key" }
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key edit run command" do
- let(:key_edit_object) {
+ let(:key_edit_object) do
described_class.new(keyname, actor, actor_field_name, ui, config)
- }
+ end
context "when the command is run" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
}
- }
+ end
let(:new_keyname) { "charizard-key" }
before do
@@ -126,12 +126,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when key_name is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => new_keyname,
}
- }
+ end
before do
key_edit_object.config[:key_name] = new_keyname
allow_any_instance_of(Chef::Key).to receive(:update)
@@ -155,14 +155,14 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key, key_name, and expiration_date are passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"name" => new_keyname,
"expiration_date" => "infinity",
}
- }
+ end
before do
key_edit_object.config[:public_key] = "this-public-key"
key_edit_object.config[:key_name] = new_keyname
@@ -177,12 +177,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when create_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"create_key" => true,
}
- }
+ end
before do
key_edit_object.config[:create_key] = true
@@ -196,12 +196,12 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end
context "when public_key is passed" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
}
- }
+ end
before do
allow(key_edit_object).to receive(:update_key_from_hash).and_return(Chef::Key.from_hash(expected_hash))
key_edit_object.config[:public_key] = "public_key_path"
@@ -214,13 +214,13 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo
end # when public_key is passed
context "when the server returns a private key" do
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"public_key" => public_key,
"private_key" => "super_private",
}
- }
+ end
before do
allow(key_edit_object).to receive(:update_key_from_hash).and_return(Chef::Key.from_hash(expected_hash))
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 2d4f0a07bb..82fd1e4a09 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -78,9 +78,9 @@ describe Chef::Knife::KeyList do
let(:ui) { instance_double("Chef::Knife::UI") }
shared_examples_for "key list run command" do
- let(:key_list_object) {
+ let(:key_list_object) do
described_class.new(actor, list_method, ui, config)
- }
+ end
before do
allow(Chef::Key).to receive(list_method).and_return(http_response)
@@ -191,26 +191,26 @@ describe Chef::Knife::KeyList do
context "when list_method is :list_by_user" do
it_should_behave_like "key list run command" do
let(:list_method) { :list_by_user }
- let(:http_response) {
+ let(:http_response) do
[
{ "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
{ "uri" => "https://api.opscode.piab/users/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
{ "uri" => "https://api.opscode.piab/users/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
- }
+ end
end
end
context "when list_method is :list_by_client" do
it_should_behave_like "key list run command" do
let(:list_method) { :list_by_client }
- let(:http_response) {
+ let(:http_response) do
[
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired1", "name" => "non-expired1", "expired" => false },
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/charmander/keys/non-expired2", "name" => "non-expired2", "expired" => false },
{ "uri" => "https://api.opscode.piab/organizations/pokemon/clients/mary/keys/out-of-date", "name" => "out-of-date", "expired" => true },
]
- }
+ end
end
end
end
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index c161efbe0d..139d4f91a2 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -78,19 +78,19 @@ describe Chef::Knife::KeyShow do
let(:actor) { "charmander" }
let(:keyname) { "charmander" }
let(:ui) { instance_double("Chef::Knife::UI") }
- let(:expected_hash) {
+ let(:expected_hash) do
{
actor_field_name => "charmander",
"name" => "charmander-key",
"public_key" => "some-public-key",
"expiration_date" => "infinity",
}
- }
+ end
shared_examples_for "key show run command" do
- let(:key_show_object) {
+ let(:key_show_object) do
described_class.new(keyname, actor, load_method, ui)
- }
+ end
before do
allow(key_show_object).to receive(:display_output)
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 473598fd85..c87ea3ad17 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -34,10 +34,11 @@ describe Chef::Knife::Status do
end
describe "run" do
- let(:opts) {{ filter_result:
+ let(:opts) do
+ { filter_result:
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"],
ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"],
- platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }}
+ platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } end
it "should default to searching for everything" do
expect(@query).to receive(:search).with(:node, "*:*", opts)
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index e708d2d1ad..07d72fd05a 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -24,13 +24,13 @@ Chef::Knife::UserCreate.load_deps
describe Chef::Knife::UserCreate do
let(:knife) { Chef::Knife::UserCreate.new }
- let(:stderr) {
+ let(:stderr) do
StringIO.new
- }
+ end
- let(:stdout) {
+ let(:stdout) do
StringIO.new
- }
+ end
before(:each) do
allow(knife.ui).to receive(:stdout).and_return(stdout)