diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /spec/unit/knife | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'spec/unit/knife')
75 files changed, 544 insertions, 611 deletions
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb index c509c70872..491d0ca754 100644 --- a/spec/unit/knife/bootstrap/client_builder_spec.rb +++ b/spec/unit/knife/bootstrap/client_builder_spec.rb @@ -18,7 +18,6 @@ require "spec_helper" - describe Chef::Knife::Bootstrap::ClientBuilder do let(:stdout) { StringIO.new } @@ -131,7 +130,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end end - context "#create_node!" do + context "#create_node!" do before do # mock out the rest of #run expect(client_builder).to receive(:sanity_check) @@ -181,8 +180,8 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end it "builds a node with first_boot_attributes if they're given" do - knife_config[:first_boot_attributes] = {:baz => :quux} - expect(node).to receive(:normal_attrs=).with({:baz=>:quux}) + knife_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 diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index e6a78df8ba..e8e75e43b5 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -51,7 +51,7 @@ describe Chef::Knife::Bootstrap do context "with --bootstrap-vault-item" do let(:bootstrap_cli_options) { [ "--bootstrap-vault-item", "vault1:item1", "--bootstrap-vault-item", "vault1:item2", "--bootstrap-vault-item", "vault2:item1" ] } it "sets the knife config cli option correctly" do - expect(knife.config[:bootstrap_vault_item]).to eq({"vault1"=>["item1", "item2"], "vault2"=>["item1"]}) + expect(knife.config[:bootstrap_vault_item]).to eq({ "vault1" => ["item1", "item2"], "vault2" => ["item1"] }) end end @@ -102,7 +102,7 @@ describe Chef::Knife::Bootstrap do context "when :bootstrap_template config is set to a template name" do let(:bootstrap_template) { "example" } - let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb"))} + let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb")) } let(:chef_config_dir_template_path) { "/knife/chef/config/bootstrap/example.erb" } @@ -209,7 +209,7 @@ describe Chef::Knife::Bootstrap do ["-d", "--distro", "-t", "--bootstrap-template", "--template-file"].each do |t| context "when #{t} option is given in the command line" do it "sets the knife :bootstrap_template config" do - knife.parse_options([t,"blahblah"]) + knife.parse_options([t, "blahblah"]) knife.merge_configs expect(knife.bootstrap_template).to eq("blahblah") end @@ -224,7 +224,7 @@ describe Chef::Knife::Bootstrap do end it "should have role[base] in the run_list" do - knife.parse_options(["-r","role[base]"]) + knife.parse_options(["-r", "role[base]"]) knife.merge_configs expect(knife.render_template).to eq('{"run_list":["role[base]"]}') end @@ -238,7 +238,7 @@ describe Chef::Knife::Bootstrap do context "with bootstrap_attribute options" do let(:jsonfile) { file = Tempfile.new (["node", ".json"]) - File.open(file.path, "w") {|f| f.puts '{"foo":{"bar":"baz"}}' } + File.open(file.path, "w") { |f| f.puts '{"foo":{"bar":"baz"}}' } file } @@ -264,7 +264,7 @@ describe Chef::Knife::Bootstrap do knife.parse_options(["-j", '{"foo":{"bar":"baz"}}']) knife.parse_options(["--json-attribute-file", jsonfile.path]) knife.merge_configs - expect{ knife.run }.to raise_error(Chef::Exceptions::BootstrapCommandInputError) + expect { knife.run }.to raise_error(Chef::Exceptions::BootstrapCommandInputError) jsonfile.close end end @@ -297,7 +297,7 @@ describe Chef::Knife::Bootstrap do k end - let(:options){ ["--bootstrap-no-proxy", setting, "-s", "foo"] } + let(:options) { ["--bootstrap-no-proxy", setting, "-s", "foo"] } let(:template_file) { File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "no_proxy.erb")) } let(:rendered_template) do knife.render_template @@ -339,7 +339,7 @@ describe Chef::Knife::Bootstrap do let(:options) { ["--node-ssl-verify-mode", "all"] } it "raises error" do - expect{ rendered_template }.to raise_error + expect { rendered_template }.to raise_error end end @@ -633,7 +633,7 @@ describe Chef::Knife::Bootstrap do describe "when falling back to password auth when host key auth fails" do let(:knife_ssh_with_password_auth) do knife.name_args = ["foo.example.com"] - knife.config[:ssh_user] = "rooty" + knife.config[:ssh_user] = "rooty" knife.config[:ssh_identity_file] = "~/.ssh/me.rsa" allow(knife).to receive(:render_template).and_return("") k = knife.knife_ssh @@ -662,7 +662,7 @@ describe Chef::Knife::Bootstrap do let(:knife_ssh) do knife.name_args = ["foo.example.com"] knife.config[:chef_node_name] = "foo.example.com" - knife.config[:ssh_user] = "rooty" + knife.config[:ssh_user] = "rooty" knife.config[:ssh_identity_file] = "~/.ssh/me.rsa" allow(knife).to receive(:render_template).and_return("") knife_ssh = knife.knife_ssh @@ -677,7 +677,6 @@ describe Chef::Knife::Bootstrap do allow(File).to receive(:exist?).with(File.expand_path(Chef::Config[:validation_key])).and_return(true) end - it "configures the underlying ssh command and then runs it" do expect(knife_ssh).to receive(:run) knife.run diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb index 42110d8180..096fba632a 100644 --- a/spec/unit/knife/client_bulk_delete_spec.rb +++ b/spec/unit/knife/client_bulk_delete_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::ClientBulkDelete do let(:stdout_io) { StringIO.new } - let(:stdout) {stdout_io.string} + let(:stdout) { stdout_io.string } let(:stderr_io) { StringIO.new } let(:stderr) { stderr_io.string } @@ -69,7 +69,7 @@ describe Chef::Knife::ClientBulkDelete do clients } - let(:client_names) { nonvalidator_client_names + validator_client_names} + let(:client_names) { nonvalidator_client_names + validator_client_names } let(:clients) { nonvalidator_clients.merge(validator_clients) } @@ -128,7 +128,7 @@ describe Chef::Knife::ClientBulkDelete do end describe "with --delete-validators" do - let(:option_args) { {:delete_validators => true} } + let(:option_args) { { :delete_validators => true } } it "should mention that validator clients will be deleted" do knife.run diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb index 7c3d837c97..bd9d4a1d63 100644 --- a/spec/unit/knife/client_create_spec.rb +++ b/spec/unit/knife/client_create_spec.rb @@ -24,7 +24,6 @@ describe Chef::Knife::ClientCreate do let(:stderr) { StringIO.new } let(:stdout) { StringIO.new } - let(:default_client_hash) do { "name" => "adam", @@ -53,7 +52,7 @@ describe Chef::Knife::ClientCreate do end before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" end describe "run" do diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb index eee665a7b4..f1af3c3d4e 100644 --- a/spec/unit/knife/client_delete_spec.rb +++ b/spec/unit/knife/client_delete_spec.rb @@ -69,7 +69,7 @@ describe Chef::Knife::ClientDelete do it "should not delete validator client if --delete-validators is not set" do @client.validator(true) expect(@knife.ui).to receive(:fatal) - expect { @knife.run}.to raise_error(SystemExit) + expect { @knife.run }.to raise_error(SystemExit) end it "should delete validator client if --delete-validators is set" do diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb index 9dfb0666de..47b4b6ccb0 100644 --- a/spec/unit/knife/client_show_spec.rb +++ b/spec/unit/knife/client_show_spec.rb @@ -36,7 +36,7 @@ describe Chef::Knife::ClientShow do @knife.config[:format] = "json" @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) - fake_client_contents = {"foo"=>"bar", "baz"=>"qux"} + fake_client_contents = { "foo" => "bar", "baz" => "qux" } expect(Chef::ApiClientV1).to receive(:load).with("adam").and_return(fake_client_contents) @knife.run expect(@stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n") diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb index 54fed02ca3..192da862d7 100644 --- a/spec/unit/knife/configure_client_spec.rb +++ b/spec/unit/knife/configure_client_spec.rb @@ -44,9 +44,9 @@ describe Chef::Knife::ConfigureClient do @client_file = StringIO.new @validation_file = StringIO.new expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w"). - and_yield(@client_file) + and_yield(@client_file) expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w"). - and_yield(@validation_file) + and_yield(@validation_file) expect(IO).to receive(:read).and_return("foo_bar_baz") end @@ -81,4 +81,3 @@ describe Chef::Knife::ConfigureClient do end end - diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 6c1d98c2f5..e96115c056 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -4,7 +4,7 @@ describe Chef::Knife::Configure do before do Chef::Log.logger = Logger.new(StringIO.new) - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::Configure.new @rest_client = double("null rest client", :post => { :result => :true }) allow(@knife).to receive(:rest).and_return(@rest_client) @@ -22,7 +22,6 @@ describe Chef::Knife::Configure do allow(Ohai::System).to receive(:new).and_return(ohai) end - let(:fqdn) { "foo.example.org" } let(:ohai) do @@ -41,7 +40,6 @@ describe Chef::Knife::Configure do let(:default_server_url) { "https://#{fqdn}:443" } - it "asks the user for the URL of the chef server" do @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the chef server URL: [#{default_server_url}]")) @@ -220,7 +218,7 @@ describe Chef::Knife::Configure do expect(File).to receive(:expand_path).with("/home/you/.chef/a-new-user.pem").and_return("/home/you/.chef/a-new-user.pem") expect(File).to receive(:expand_path).with(default_validator_key).and_return(default_validator_key) expect(File).to receive(:expand_path).with(default_admin_key).and_return(default_admin_key) - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" user_command = Chef::Knife::UserCreate.new expect(user_command).to receive(:run) diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index 72299f4920..62b8c9fe51 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -22,9 +22,9 @@ describe Chef::Knife::CookbookBulkDelete do before(:each) do Chef::Log.logger = Logger.new(StringIO.new) - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookBulkDelete.new - @knife.config = {:print_after => nil} + @knife.config = { :print_after => nil } @knife.name_args = ["."] @stdout = StringIO.new @stderr = StringIO.new @@ -44,15 +44,13 @@ describe Chef::Knife::CookbookBulkDelete do end - - describe "when there are several cookbooks on the server" do before do - @cheezburger = {"cheezburger" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-cheez", "version" => "1.0.0"}]}} + @cheezburger = { "cheezburger" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-cheez", "version" => "1.0.0" }] } } allow(@rest).to receive(:get).with("cookbooks/cheezburger").and_return(@cheezburger) - @pizza = {"pizza" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-pizza", "version" => "2.0.0"}]}} + @pizza = { "pizza" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-pizza", "version" => "2.0.0" }] } } allow(@rest).to receive(:get).with("cookbooks/pizza").and_return(@pizza) - @lasagna = {"lasagna" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-lasagna", "version" => "3.0.0"}]}} + @lasagna = { "lasagna" => { "url" => "file:///dev/null", "versions" => [{ "url" => "file:///dev/null-lasagna", "version" => "3.0.0" }] } } allow(@rest).to receive(:get).with("cookbooks/lasagna").and_return(@lasagna) end @@ -68,7 +66,7 @@ describe Chef::Knife::CookbookBulkDelete do end it "should delete each cookbook" do - {"cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => "3.0.0"}.each do |cookbook_name, version| + { "cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => "3.0.0" }.each do |cookbook_name, version| expect(@rest).to receive(:delete).with("cookbooks/#{cookbook_name}/#{version}") end @knife.run diff --git a/spec/unit/knife/cookbook_create_spec.rb b/spec/unit/knife/cookbook_create_spec.rb index 1989516c1b..a183bef103 100644 --- a/spec/unit/knife/cookbook_create_spec.rb +++ b/spec/unit/knife/cookbook_create_spec.rb @@ -21,7 +21,7 @@ require "tmpdir" describe Chef::Knife::CookbookCreate do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookCreate.new @knife.config = {} @knife.name_args = ["foobar"] @@ -34,7 +34,7 @@ describe Chef::Knife::CookbookCreate do # Fixes CHEF-2579 it "should expand the path of the cookbook directory" do expect(File).to receive(:expand_path).with("~/tmp/monkeypants") - @knife.config = {:cookbook_path => "~/tmp/monkeypants"} + @knife.config = { :cookbook_path => "~/tmp/monkeypants" } allow(@knife).to receive(:create_cookbook) allow(@knife).to receive(:create_readme) allow(@knife).to receive(:create_changelog) @@ -44,7 +44,7 @@ describe Chef::Knife::CookbookCreate do it "should create a new cookbook with default values to copyright name, email, readme format and license if those are not supplied" do @dir = Dir.tmpdir - @knife.config = {:cookbook_path => @dir} + @knife.config = { :cookbook_path => @dir } expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "YOUR_COMPANY_NAME", "none") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -58,7 +58,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_path => @dir, :cookbook_copyright => "Opscode, Inc", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -73,7 +73,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_copyright => "Opscode, Inc", :cookbook_email => "nuo@opscode.com", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -89,7 +89,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => "apachev2", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "apachev2") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -105,7 +105,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => false, } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -121,7 +121,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => "false", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "none") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -137,7 +137,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => "gplv2", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv2") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -153,7 +153,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => "gplv3", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "gplv3") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -169,7 +169,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_email => "nuo@opscode.com", :cookbook_license => "mit", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "md") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -186,7 +186,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_license => "mit", :readme_format => "rdoc", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "rdoc") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -203,7 +203,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_license => "mit", :readme_format => "mkd", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "mkd") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -220,7 +220,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_license => "mit", :readme_format => "txt", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "txt") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -237,7 +237,7 @@ describe Chef::Knife::CookbookCreate do :cookbook_license => "mit", :readme_format => "foo", } - @knife.name_args=["foobar"] + @knife.name_args = ["foobar"] expect(@knife).to receive(:create_cookbook).with(@dir, @knife.name_args.first, "Opscode, Inc", "mit") expect(@knife).to receive(:create_readme).with(@dir, @knife.name_args.first, "foo") expect(@knife).to receive(:create_changelog).with(@dir, @knife.name_args.first) @@ -252,7 +252,7 @@ describe Chef::Knife::CookbookCreate do it "should throw an argument error" do @dir = Dir.tmpdir - expect{@knife.run}.to raise_error(ArgumentError) + expect { @knife.run }.to raise_error(ArgumentError) end end diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb index f27bfeaa80..4bca4e06ed 100644 --- a/spec/unit/knife/cookbook_delete_spec.rb +++ b/spec/unit/knife/cookbook_delete_spec.rb @@ -63,7 +63,7 @@ describe Chef::Knife::CookbookDelete do it "should prompt to purge the files" do @knife.config[:purge] = true expect(@knife).to receive(:confirm). - with(/.+Are you sure you want to purge files.+/) + with(/.+Are you sure you want to purge files.+/) expect(@knife).to receive(:delete_without_explicit_version) @knife.run end @@ -127,9 +127,9 @@ describe Chef::Knife::CookbookDelete do before(:each) do @rest_mock = double("rest") expect(@knife).to receive(:rest).and_return(@rest_mock) - @cookbook_data = { "foobar" => { "versions" => [{"version" => "1.0.0"}, - {"version" => "1.1.0"}, - {"version" => "2.0.0"} ]} + @cookbook_data = { "foobar" => { "versions" => [{ "version" => "1.0.0" }, + { "version" => "1.1.0" }, + { "version" => "2.0.0" } ] } } end diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index c515693a53..a8248a80b9 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -49,20 +49,20 @@ describe Chef::Knife::CookbookDownload do @manifest_data = { :recipes => [ - {"path" => "recipes/foo.rb", - "url" => "http://example.org/files/foo.rb"}, - {"path" => "recipes/bar.rb", - "url" => "http://example.org/files/bar.rb"}, + { "path" => "recipes/foo.rb", + "url" => "http://example.org/files/foo.rb" }, + { "path" => "recipes/bar.rb", + "url" => "http://example.org/files/bar.rb" }, ], :templates => [ - {"path" => "templates/default/foo.erb", - "url" => "http://example.org/files/foo.erb"}, - {"path" => "templates/default/bar.erb", - "url" => "http://example.org/files/bar.erb"}, + { "path" => "templates/default/foo.erb", + "url" => "http://example.org/files/foo.erb" }, + { "path" => "templates/default/bar.erb", + "url" => "http://example.org/files/bar.erb" }, ], :attributes => [ - {"path" => "attributes/default.rb", - "url" => "http://example.org/files/default.rb"}, + { "path" => "attributes/default.rb", + "url" => "http://example.org/files/default.rb" }, ], } @@ -102,17 +102,17 @@ describe Chef::Knife::CookbookDownload do before(:each) do @files.map { |f| File.dirname(f) }.flatten.uniq.each do |dir| expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}"). - at_least(:once) + at_least(:once) end @files_mocks.each_pair do |file, mock| expect(@rest_mock).to receive(:streaming_request).with("http://example.org/files/#{file}"). - and_return(mock) + and_return(mock) end @files.each do |f| expect(FileUtils).to receive(:mv). - with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}") + with("/var/tmp/#{File.basename(f)}", "/var/tmp/chef/foobar-1.0.0/#{f}") end end @@ -165,7 +165,7 @@ describe Chef::Knife::CookbookDownload do it "should return and set the version to the latest version" do @knife.config[:latest] = true expect(@knife).to receive(:available_versions).at_least(:once). - and_return(["1.0.0", "1.1.0", "2.0.0"]) + and_return(["1.0.0", "1.1.0", "2.0.0"]) @knife.determine_version expect(@knife.version.to_s).to eq("2.0.0") end @@ -179,15 +179,15 @@ describe Chef::Knife::CookbookDownload do it "should return nil if there are no versions" do expect(Chef::CookbookVersion).to receive(:available_versions). - with("foobar"). - and_return(nil) + with("foobar"). + and_return(nil) expect(@knife.available_versions).to eq(nil) end it "should return the available versions" do expect(Chef::CookbookVersion).to receive(:available_versions). - with("foobar"). - and_return(["1.1.0", "2.0.0", "1.0.0"]) + with("foobar"). + and_return(["1.1.0", "2.0.0", "1.0.0"]) expect(@knife.available_versions).to eq([Chef::Version.new("1.0.0"), Chef::Version.new("1.1.0"), Chef::Version.new("2.0.0")]) @@ -195,9 +195,9 @@ describe Chef::Knife::CookbookDownload do it "should avoid multiple API calls to the server" do expect(Chef::CookbookVersion).to receive(:available_versions). - once. - with("foobar"). - and_return(["1.1.0", "2.0.0", "1.0.0"]) + once. + with("foobar"). + and_return(["1.1.0", "2.0.0", "1.0.0"]) @knife.available_versions @knife.available_versions end diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb index cc45970ead..668f9afa4b 100644 --- a/spec/unit/knife/cookbook_list_spec.rb +++ b/spec/unit/knife/cookbook_list_spec.rb @@ -27,9 +27,9 @@ describe Chef::Knife::CookbookList do @base_url = "https://server.example.com/cookbooks" @cookbook_data = {} @cookbook_names.each do |item| - @cookbook_data[item] = {"url" => "#{@base_url}/#{item}", - "versions" => [{"version" => "1.0.1", - "url" => "#{@base_url}/#{item}/1.0.1"}]} + @cookbook_data[item] = { "url" => "#{@base_url}/#{item}", + "versions" => [{ "version" => "1.0.1", + "url" => "#{@base_url}/#{item}/1.0.1" }] } end @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) @@ -38,7 +38,7 @@ describe Chef::Knife::CookbookList do describe "run" do it "should display the latest version of the cookbooks" do expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=1"). - and_return(@cookbook_data) + and_return(@cookbook_data) @knife.run @cookbook_names.each do |item| expect(@stdout.string).to match /#{item}\s+1\.0\.1/ @@ -48,8 +48,8 @@ describe Chef::Knife::CookbookList do it "should query cookbooks for the configured environment" do @knife.config[:environment] = "production" expect(@rest_mock).to receive(:get). - with("/environments/production/cookbooks?num_versions=1"). - and_return(@cookbook_data) + with("/environments/production/cookbooks?num_versions=1"). + and_return(@cookbook_data) @knife.run end @@ -68,15 +68,15 @@ describe Chef::Knife::CookbookList do describe "with -a or --all" do before do @cookbook_names.each do |item| - @cookbook_data[item]["versions"] << {"version" => "1.0.0", - "url" => "#{@base_url}/#{item}/1.0.0"} + @cookbook_data[item]["versions"] << { "version" => "1.0.0", + "url" => "#{@base_url}/#{item}/1.0.0" } end end it "should display all versions of the cookbooks" do @knife.config[:all_versions] = true expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all"). - and_return(@cookbook_data) + and_return(@cookbook_data) @knife.run @cookbook_names.each do |item| expect(@stdout.string).to match /#{item}\s+1\.0\.1\s+1\.0\.0/ diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb index f09a4fc53c..274eb5e167 100644 --- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb +++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb @@ -22,7 +22,7 @@ require "spec_helper" describe Chef::Knife::CookbookMetadataFromFile do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @src = File.expand_path(File.join(CHEF_SPEC_DATA, "metadata", "quick_start", "metadata.rb")) @tgt = File.expand_path(File.join(CHEF_SPEC_DATA, "metadata", "quick_start", "metadata.json")) @knife = Chef::Knife::CookbookMetadataFromFile.new diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb index 2f6480a06b..0e3fccfa7e 100644 --- a/spec/unit/knife/cookbook_metadata_spec.rb +++ b/spec/unit/knife/cookbook_metadata_spec.rb @@ -85,19 +85,19 @@ describe Chef::Knife::CookbookMetadata do before(:each) do @knife.config[:cookbook_path] = @cookbook_dir allow(File).to receive(:expand_path).with("#{@cookbook_dir}/foobar/metadata.rb"). - and_return("#{@cookbook_dir}/foobar/metadata.rb") + and_return("#{@cookbook_dir}/foobar/metadata.rb") end it "should generate the metadata from metadata.rb if it exists" do expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb"). - and_return(true) + and_return(true) expect(@knife).to receive(:generate_metadata_from_file).with("foobar", "#{@cookbook_dir}/foobar/metadata.rb") @knife.run end it "should validate the metadata json if metadata.rb does not exist" do expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb"). - and_return(false) + and_return(false) expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, "foobar") @knife.run end @@ -114,10 +114,10 @@ describe Chef::Knife::CookbookMetadata do expect(@metadata_mock).to receive(:name).with("foobar") expect(@metadata_mock).to receive(:from_file).with("#{@cookbook_dir}/foobar/metadata.rb") expect(File).to receive(:open).with("#{@cookbook_dir}/foobar/metadata.json", "w"). - and_yield(@json_file_mock) + and_yield(@json_file_mock) expect(@json_file_mock).to receive(:write).with(@json_data) expect(Chef::JSONCompat).to receive(:to_json_pretty).with(@metadata_mock). - and_return(@json_data) + and_return(@json_data) @knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb") expect(@stderr.string).to match /generating metadata for foobar from #{@cookbook_dir}\/foobar\/metadata\.rb/im end @@ -141,16 +141,16 @@ describe Chef::Knife::CookbookMetadata do describe "validate_metadata_json" do it "should validate the metadata json" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). - and_return(true) + and_return(true) expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json"). - and_return(@json_data) + and_return(@json_data) expect(Chef::Cookbook::Metadata).to receive(:validate_json).with(@json_data) @knife.validate_metadata_json(@cookbook_dir, "foobar") end it "should not try to validate the metadata json if the file does not exist" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). - and_return(false) + and_return(false) expect(IO).not_to receive(:read) expect(Chef::Cookbook::Metadata).not_to receive(:validate_json) @knife.validate_metadata_json(@cookbook_dir, "foobar") @@ -161,9 +161,9 @@ describe Chef::Knife::CookbookMetadata do }.each_pair do |klass, description| it "should print an error and exit when an #{description} syntax exception is encountered" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). - and_return(true) + and_return(true) expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json"). - and_return(@json_data) + and_return(@json_data) exception = klass.new("#{description} blah") allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception) expect { diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb index ee9fb1c081..de6d569e1d 100644 --- a/spec/unit/knife/cookbook_show_spec.rb +++ b/spec/unit/knife/cookbook_show_spec.rb @@ -21,9 +21,9 @@ require "spec_helper" describe Chef::Knife::CookbookShow do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookShow.new - @knife.config = { } + @knife.config = {} @knife.name_args = [ "cookbook_name" ] @rest = double(Chef::ServerAPI) allow(@knife).to receive(:rest).and_return(@rest) @@ -72,7 +72,7 @@ describe Chef::Knife::CookbookShow do describe "with 2 arguments: name and version" do before(:each) do @knife.name_args << "0.1.0" - @response = { "0.1.0" => { "recipes" => {"default.rb" => ""} } } + @response = { "0.1.0" => { "recipes" => { "default.rb" => "" } } } end it "should show the specific part of a cookbook" do @@ -97,7 +97,7 @@ describe Chef::Knife::CookbookShow do ] } @cookbook_response.manifest = @manifest - @response = {"name"=>"default.rb", "url"=>"http://example.org/files/default.rb", "checksum"=>"1234", "path"=>"recipes/default.rb"} + @response = { "name" => "default.rb", "url" => "http://example.org/files/default.rb", "checksum" => "1234", "path" => "recipes/default.rb" } end it "should print the json of the part" do @@ -220,4 +220,3 @@ describe Chef::Knife::CookbookShow do end end end - diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb index 530ac576e0..663ad1af74 100644 --- a/spec/unit/knife/cookbook_site_download_spec.rb +++ b/spec/unit/knife/cookbook_site_download_spec.rb @@ -36,8 +36,8 @@ describe Chef::Knife::CookbookSiteDownload do allow(@knife.ui).to receive(:stderr).and_return(@stderr) allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest) expect(@noauth_rest).to receive(:get). - with("#{@cookbook_api_url}/apache2"). - and_return(@current_data) + with("#{@cookbook_api_url}/apache2"). + and_return(@current_data) end context "when the cookbook is deprecated and not forced" do @@ -47,9 +47,9 @@ describe Chef::Knife::CookbookSiteDownload do it "should warn with info about the replacement" do expect(@knife.ui).to receive(:warn). - with(/.+deprecated.+replaced by other_apache2.+/i) + with(/.+deprecated.+replaced by other_apache2.+/i) expect(@knife.ui).to receive(:warn). - with(/use --force.+download.+/i) + with(/use --force.+download.+/i) @knife.run end end @@ -58,7 +58,7 @@ describe Chef::Knife::CookbookSiteDownload do before do @cookbook_data = { "version" => @version, "file" => "http://example.com/apache2_#{@version_us}.tgz" } - @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" ) + @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" ) @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") expect(@noauth_rest).to receive(:sign_on_redirect=).with(false) @@ -67,11 +67,11 @@ describe Chef::Knife::CookbookSiteDownload do context "downloading the latest version" do before do expect(@noauth_rest).to receive(:get). - with(@current_data["latest_version"]). - and_return(@cookbook_data) + with(@current_data["latest_version"]). + and_return(@cookbook_data) expect(@noauth_rest).to receive(:get). - with(@cookbook_data["file"], true). - and_return(@temp_file) + with(@cookbook_data["file"], true). + and_return(@temp_file) end context "and it is deprecated and with --force" do @@ -82,7 +82,7 @@ describe Chef::Knife::CookbookSiteDownload do it "should download the latest version" do expect(@knife.ui).to receive(:warn). - with(/.+deprecated.+replaced by other_apache2.+/i) + with(/.+deprecated.+replaced by other_apache2.+/i) expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @knife.run expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i @@ -132,11 +132,11 @@ describe Chef::Knife::CookbookSiteDownload do it "should download the desired version" do expect(@noauth_rest).to receive(:get). - with("#{@cookbook_api_url}/apache2/versions/#{@version_us}"). - and_return(@cookbook_data) + with("#{@cookbook_api_url}/apache2/versions/#{@version_us}"). + and_return(@cookbook_data) expect(@noauth_rest).to receive(:get). - with(@cookbook_data["file"], true). - and_return(@temp_file) + with(@cookbook_data["file"], true). + and_return(@temp_file) expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @knife.run expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index 051a3ed168..662b53dd29 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -145,8 +145,8 @@ describe Chef::Knife::CookbookSiteShare do it "should list files in the tarball" do allow(@knife).to receive(:tar_cmd).and_return("footar") - expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", {:cwd => "/var/tmp/dummy"}) - expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", {:cwd => "/var/tmp/dummy"}) + expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { :cwd => "/var/tmp/dummy" }) + expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { :cwd => "/var/tmp/dummy" }) @knife.run end @@ -172,7 +172,7 @@ describe Chef::Knife::CookbookSiteShare do end it 'should post the cookbook to "https://supermarket.chef.io"' do - response_text = Chef::JSONCompat.to_json({:uri => "https://supermarket.chef.io/cookbooks/cookbook_name"}) + response_text = Chef::JSONCompat.to_json({ :uri => "https://supermarket.chef.io/cookbooks/cookbook_name" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(201) expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything()) @@ -180,7 +180,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should alert the user when a version already exists" do - response_text = Chef::JSONCompat.to_json({:error_messages => ["Version already exists"]}) + response_text = Chef::JSONCompat.to_json({ :error_messages => ["Version already exists"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(409) expect { @knife.run }.to raise_error(SystemExit) @@ -188,7 +188,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should pass any errors on to the user" do - response_text = Chef::JSONCompat.to_json({:error_messages => ["You're holding it wrong"]}) + response_text = Chef::JSONCompat.to_json({ :error_messages => ["You're holding it wrong"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(403) expect { @knife.run }.to raise_error(SystemExit) @@ -196,7 +196,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should print the body if no errors are exposed on failure" do - response_text = Chef::JSONCompat.to_json({:system_error => "Your call was dropped", :reason => "There's a map for that"}) + response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(500) expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered diff --git a/spec/unit/knife/cookbook_test_spec.rb b/spec/unit/knife/cookbook_test_spec.rb index 841ebe5f6f..abb88fe739 100644 --- a/spec/unit/knife/cookbook_test_spec.rb +++ b/spec/unit/knife/cookbook_test_spec.rb @@ -23,9 +23,9 @@ Chef::Knife::CookbookTest.load_deps describe Chef::Knife::CookbookTest do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookTest.new - @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA,"cookbooks") + @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA, "cookbooks") allow(@knife.cookbook_loader).to receive(:cookbook_exists?).and_return(true) @cookbooks = [] %w{tats central_market jimmy_johns pho}.each do |cookbook_name| diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb index 1445f8c086..dc55a709b7 100644 --- a/spec/unit/knife/cookbook_upload_spec.rb +++ b/spec/unit/knife/cookbook_upload_spec.rb @@ -26,7 +26,7 @@ describe Chef::Knife::CookbookUpload do let(:cookbook) { Chef::CookbookVersion.new("test_cookbook", "/tmp/blah.txt") } let(:cookbooks_by_name) do - {cookbook.name => cookbook} + { cookbook.name => cookbook } end let(:cookbook_loader) do @@ -62,8 +62,8 @@ describe Chef::Knife::CookbookUpload do allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook) allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"]) expect(Chef::CookbookUploader).to receive(:new). - with( kind_of(Array), { :force => nil, :concurrency => 3}). - and_return(double("Chef::CookbookUploader", :upload_cookbooks=> true)) + with( kind_of(Array), { :force => nil, :concurrency => 3 }). + and_return(double("Chef::CookbookUploader", :upload_cookbooks => true)) knife.run end end @@ -107,12 +107,12 @@ describe Chef::Knife::CookbookUpload do before do allow(cookbook_loader).to receive(:merged_cookbooks).and_return(["test_cookbook"]) allow(cookbook_loader).to receive(:merged_cookbook_paths). - and_return({"test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook}}) + and_return({ "test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook} }) end it "emits a warning" do knife.run - expected_message=<<-E + expected_message = <<-E WARNING: The cookbooks: test_cookbook exist in multiple places in your cookbook_path. A composite version of these cookbooks has been compiled for uploading. @@ -196,9 +196,9 @@ E before(:each) do cookbook.metadata.depends("dependency") - allow(cookbook_loader).to receive(:[]) do |ckbk| + allow(cookbook_loader).to receive(:[]) do |ckbk| { "test_cookbook" => cookbook, - "dependency" => cookbook_dependency}[ckbk] + "dependency" => cookbook_dependency }[ckbk] end allow(knife).to receive(:cookbook_names).and_return(["cookbook_dependency", "test_cookbook"]) @stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new @@ -209,11 +209,11 @@ E expect(cookbook_loader).to receive(:[]).once.with("test_cookbook") expect(cookbook_loader).not_to receive(:load_cookbooks) expect(cookbook_uploader).not_to receive(:upload_cookbooks) - expect {knife.run}.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "should output a message for a single missing dependency" do - expect {knife.run}.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently") expect(@stderr.string).to include("being uploaded and cannot be found on the server.") expect(@stderr.string).to include("The missing cookbook(s) are: 'dependency' version '>= 0.0.0'") @@ -222,13 +222,13 @@ E it "should output a message for a multiple missing dependencies which are concatenated" do cookbook_dependency2 = Chef::CookbookVersion.new("dependency2") cookbook.metadata.depends("dependency2") - allow(cookbook_loader).to receive(:[]) do |ckbk| + allow(cookbook_loader).to receive(:[]) do |ckbk| { "test_cookbook" => cookbook, "dependency" => cookbook_dependency, - "dependency2" => cookbook_dependency2}[ckbk] + "dependency2" => cookbook_dependency2 }[ckbk] end allow(knife).to receive(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"]) - expect {knife.run}.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently") expect(@stderr.string).to include("being uploaded and cannot be found on the server.") expect(@stderr.string).to include("The missing cookbook(s) are:") diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 16c0867610..efcc2659dd 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -26,7 +26,7 @@ describe Chef::Knife::Core::BootstrapContext do Chef::Config[:fips] = false end - let(:config) { {:foo => :bar, :color => true} } + let(:config) { { :foo => :bar, :color => true } } let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") } let(:chef_config) do { @@ -41,7 +41,7 @@ describe Chef::Knife::Core::BootstrapContext do subject(:bootstrap_context) { described_class.new(config, run_list, chef_config, secret) } it "initializes with Chef 11 parameters" do - expect{described_class.new(config, run_list, chef_config)}.not_to raise_error + expect { described_class.new(config, run_list, chef_config) }.not_to raise_error end it "runs chef with the first-boot.json with no environment specified" do @@ -49,14 +49,14 @@ describe Chef::Knife::Core::BootstrapContext do end describe "when in verbosity mode" do - let(:config) { {:verbosity => 2, :color => true} } + let(:config) { { :verbosity => 2, :color => true } } it "adds '-l debug' when verbosity is >= 2" do expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug" end end describe "when no color value has been set in config" do - let(:config) { {:color => false } } + let(:config) { { :color => false } } it "adds '--no-color' when color is false" do expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json --no-color" end @@ -67,7 +67,7 @@ describe Chef::Knife::Core::BootstrapContext do end it "generates the config file data" do - expected=<<-EXPECTED + expected = <<-EXPECTED log_location STDOUT chef_server_url "http://chef.example.com:4444" validation_client_name "chef-validator-testing" @@ -81,14 +81,14 @@ EXPECTED end describe "alternate chef-client path" do - let(:chef_config){ {:chef_client_path => "/usr/local/bin/chef-client"} } + let(:chef_config) { { :chef_client_path => "/usr/local/bin/chef-client" } } it "runs chef-client from another path when specified" do expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json" end end describe "validation key path that contains a ~" do - let(:chef_config){ {:validation_key => "~/my.key"} } + let(:chef_config) { { :validation_key => "~/my.key" } } it "reads the validation key when it contains a ~" do expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV["HOME"])).and_return(true) expect(IO).to receive(:read).with(File.expand_path("my.key", ENV["HOME"])) @@ -97,36 +97,36 @@ EXPECTED end describe "when an explicit node name is given" do - let(:config){ {:chef_node_name => "foobar.example.com" }} + let(:config) { { :chef_node_name => "foobar.example.com" } } it "sets the node name in the client.rb" do expect(bootstrap_context.config_content).to match(/node_name "foobar\.example\.com"/) end end describe "when bootstrapping into a specific environment" do - let(:config){ {:environment => "prodtastic", :color => true} } + let(:config) { { :environment => "prodtastic", :color => true } } it "starts chef in the configured environment" do expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic") end end describe "when tags are given" do - let(:config) { {:tags => [ "unicorn" ] } } + let(:config) { { :tags => [ "unicorn" ] } } it "adds the attributes to first_boot" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:run_list => run_list, :tags => ["unicorn"]})) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list, :tags => ["unicorn"] })) end end describe "when JSON attributes are given" do - let(:config) { {:first_boot_attributes => {:baz => :quux}} } + let(:config) { { :first_boot_attributes => { :baz => :quux } } } it "adds the attributes to first_boot" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list})) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :baz => :quux, :run_list => run_list })) end end describe "when JSON attributes are NOT given" do it "sets first_boot equal to run_list" do - expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:run_list => run_list})) + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({ :run_list => run_list })) end end @@ -160,7 +160,7 @@ EXPECTED describe "when a bootstrap_version is specified" do let(:chef_config) do { - :knife => {:bootstrap_version => "11.12.4" } + :knife => { :bootstrap_version => "11.12.4" } } end @@ -172,7 +172,7 @@ EXPECTED describe "when a pre-release bootstrap_version is specified" do let(:chef_config) do { - :knife => {:bootstrap_version => "11.12.4.rc.0" } + :knife => { :bootstrap_version => "11.12.4.rc.0" } } end @@ -196,7 +196,7 @@ EXPECTED describe "when configured in config" do let(:chef_config) do { - :knife => {:ssl_verify_mode => :verify_peer} + :knife => { :ssl_verify_mode => :verify_peer } } end @@ -205,7 +205,7 @@ EXPECTED end describe "when configured via CLI" do - let(:config) {{:node_ssl_verify_mode => "none"}} + let(:config) { { :node_ssl_verify_mode => "none" } } it "uses CLI value" do expect(bootstrap_context.config_content).to include("ssl_verify_mode :verify_none") @@ -222,7 +222,7 @@ EXPECTED describe "when configured in config" do let(:chef_config) do { - :knife => {:verify_api_cert => :false} + :knife => { :verify_api_cert => :false } } end @@ -231,7 +231,7 @@ EXPECTED end describe "when configured via CLI" do - let(:config) {{:node_verify_api_cert => true}} + let(:config) { { :node_verify_api_cert => true } } it "uses CLI value" do expect(bootstrap_context.config_content).to include("verify_api_cert true") @@ -246,7 +246,7 @@ EXPECTED end describe "when configured via cli" do - let(:config) {{:prerelease => true}} + let(:config) { { :prerelease => true } } it "uses CLI value" do expect(bootstrap_context.latest_current_chef_version_string).to eq("-p") diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb index d1f5aeef85..137bdddafb 100644 --- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb +++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb @@ -49,7 +49,7 @@ BRANCHES describe "when sanity checking the repo" do it "exits when the directory does not exist" do expect(::File).to receive(:directory?).with(@repo_path).and_return(false) - expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) + expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end describe "and the repo dir exists" do @@ -59,7 +59,7 @@ BRANCHES it "exits when there is no git repo" do allow(::File).to receive(:directory?).with(/.*\.git/).and_return(false) - expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) + expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end describe "and the repo is a git repo" do @@ -68,9 +68,9 @@ BRANCHES end it "exits when the default branch doesn't exist" do - @nobranches = Mixlib::ShellOut.new.tap {|s|s.stdout.replace "\n"} + @nobranches = Mixlib::ShellOut.new.tap { |s| s.stdout.replace "\n" } expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches) - expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) + expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end describe "and the default branch exists" do @@ -86,12 +86,12 @@ BRANCHES M chef/lib/chef/knife/cookbook_site_vendor.rb DIRTY expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status) - expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) + expect { @cookbook_repo.sanity_check }.to raise_error(SystemExit) end describe "and the repo is clean" do before do - @clean_status = Mixlib::ShellOut.new.tap {|s| s.stdout.replace("\n")} + @clean_status = Mixlib::ShellOut.new.tap { |s| s.stdout.replace("\n") } allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status) end diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb index 9fd880a810..69a40ebaed 100644 --- a/spec/unit/knife/core/gem_glob_loader_spec.rb +++ b/spec/unit/knife/core/gem_glob_loader_spec.rb @@ -18,14 +18,14 @@ require "spec_helper" describe Chef::Knife::SubcommandLoader::GemGlobLoader do - let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) } - let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") } - let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") } + let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) } + let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") } + let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") } - before do - allow(ChefConfig).to receive(:windows?) { false } - Chef::Util::PathHelper.class_variable_set(:@@home_dir, home) - end + before do + allow(ChefConfig).to receive(:windows?) { false } + Chef::Util::PathHelper.class_variable_set(:@@home_dir, home) + end after do Chef::Util::PathHelper.class_variable_set(:@@home_dir, nil) @@ -40,7 +40,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do it "finds files installed via rubygems" do expect(loader.find_subcommands_via_rubygems).to include("chef/knife/node_create") - loader.find_subcommands_via_rubygems.each {|rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+})} + loader.find_subcommands_via_rubygems.each { |rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+}) } end it "finds files from latest version of installed gems" do @@ -65,7 +65,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do it "finds files using a dirglob when rubygems is not available" do expect(loader.find_subcommands_via_dirglob).to include("chef/knife/node_create") - loader.find_subcommands_via_dirglob.each {|rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+})} + loader.find_subcommands_via_dirglob.each { |rel_path, abs_path| expect(abs_path).to match(%r{chef/knife/.+}) } end it "finds user-specific subcommands in the user's ~/.chef directory" do @@ -178,7 +178,6 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do allow(ENV).to receive(:[]).with("HOME").and_return(env_home) end - it "searches rubygems for plugins" do if Gem::Specification.respond_to?(:latest_specs) expect(Gem::Specification).to receive(:latest_specs).and_call_original diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb index ca9aeec60c..d9f5e5761c 100644 --- a/spec/unit/knife/core/hashed_command_loader_spec.rb +++ b/spec/unit/knife/core/hashed_command_loader_spec.rb @@ -47,11 +47,11 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do describe "#list_commands" do it "lists all commands by category when no argument is given" do - expect(loader.list_commands).to eq({"cool" => ["cool_a"], "cooler" => ["cooler_b"]}) + expect(loader.list_commands).to eq({ "cool" => ["cool_a"], "cooler" => ["cooler_b"] }) end it "lists only commands in the given category when a category is given" do - expect(loader.list_commands("cool")).to eq({"cool" => ["cool_a"]}) + expect(loader.list_commands("cool")).to eq({ "cool" => ["cool_a"] }) end end diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb index e64faebf6b..32ce402e19 100644 --- a/spec/unit/knife/core/node_editor_spec.rb +++ b/spec/unit/knife/core/node_editor_spec.rb @@ -43,7 +43,7 @@ describe Chef::Knife::NodeEditor do describe '#view' do it "returns a Hash with only the name, chef_environment, normal, " + - "policy_name, policy_group, and run_list properties" do + "policy_name, policy_group, and run_list properties" do expected = node_data.select do |key,| %w{ name chef_environment normal policy_name policy_group run_list }.include?(key) @@ -74,7 +74,7 @@ describe Chef::Knife::NodeEditor do expect(ui).to have_received(:warn) .with "Changing the name of a node results in a new node being " + - "created, test_node will not be modified or removed." + "created, test_node will not be modified or removed." expect(ui).to have_received(:confirm) .with("Proceed with creation of new node") @@ -189,7 +189,7 @@ describe Chef::Knife::NodeEditor do end it 'returns an array of property names that doesn\'t include ' + - "the non-editable properties" do + "the non-editable properties" do expect(subject.updated?).to eql %w{ normal policy_name policy_group run_list } end end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 13fd304a2e..d2381f60cb 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -46,7 +46,7 @@ describe Chef::Knife::UI do context "when editing is disabled" do before do @ui.config[:disable_editing] = true - stub_const("Tempfile", double) # Tempfiles should never be invoked + stub_const("Tempfile", double) # Tempfiles should never be invoked end context "when parse_output is false" do it "returns pretty json string" do @@ -97,7 +97,7 @@ describe Chef::Knife::UI do expect(IO).not_to receive(:read) end it "throws an exception" do - expect{ subject }.to raise_error(RuntimeError) + expect { subject }.to raise_error(RuntimeError) end end context "when running the editor fails with false" do @@ -106,7 +106,7 @@ describe Chef::Knife::UI do expect(IO).not_to receive(:read) end it "throws an exception" do - expect{ subject }.to raise_error(RuntimeError) + expect { subject }.to raise_error(RuntimeError) end end end @@ -166,20 +166,20 @@ describe Chef::Knife::UI do it "should throw Errno::EIO exceptions" do allow(@out).to receive(:puts).and_raise(Errno::EIO) allow(@err).to receive(:puts).and_raise(Errno::EIO) - expect {@ui.send(method, "hi")}.to raise_error(Errno::EIO) + expect { @ui.send(method, "hi") }.to raise_error(Errno::EIO) end it "should ignore Errno::EPIPE exceptions (CHEF-3516)" do allow(@out).to receive(:puts).and_raise(Errno::EPIPE) allow(@err).to receive(:puts).and_raise(Errno::EPIPE) - expect {@ui.send(method, "hi")}.to raise_error(SystemExit) + expect { @ui.send(method, "hi") }.to raise_error(SystemExit) end it "should throw Errno::EPIPE exceptions with -VV (CHEF-3516)" do @config[:verbosity] = 2 allow(@out).to receive(:puts).and_raise(Errno::EPIPE) allow(@err).to receive(:puts).and_raise(Errno::EPIPE) - expect {@ui.send(method, "hi")}.to raise_error(Errno::EPIPE) + expect { @ui.send(method, "hi") }.to raise_error(Errno::EPIPE) end end @@ -192,7 +192,7 @@ describe Chef::Knife::UI do end it "formats hashes appropriately" do - @ui.output({"hi" => "a", "lo" => "b" }) + @ui.output({ "hi" => "a", "lo" => "b" }) expect(@out.string).to eq <<EOM hi: a lo: b @@ -318,7 +318,7 @@ EOM end it "formats hashes with empty hash values appropriately" do - @ui.output({ "a" => { }, "b" => "c" }) + @ui.output({ "a" => {}, "b" => "c" }) expect(@out.string).to eq <<EOM a: b: c @@ -354,7 +354,7 @@ EOM it "should return multiple attributes" do input = { "gi" => "go", "hi" => "ho", "id" => "sample-data-bag-item" } @ui.config[:attribute] = ["gi", "hi"] - expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi"=> "ho" } }) + expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "gi" => "go", "hi" => "ho" } }) end it "should handle attributes named the same as methods" do @@ -364,7 +364,7 @@ EOM end it "should handle nested attributes named the same as methods" do - input = { "keys" => {"keys" => "values"}, "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } @ui.config[:attribute] = "keys.keys" expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { "keys.keys" => "values" } }) end @@ -373,11 +373,11 @@ EOM allow_any_instance_of(Chef::Node).to receive(:name).and_return("chef.localdomain") input = Chef::Node.new @ui.config[:attribute] = "name" - expect(@ui.format_for_display(input)).to eq( {"chef.localdomain"=>{"name"=>"chef.localdomain"} }) + expect(@ui.format_for_display(input)).to eq( { "chef.localdomain" => { "name" => "chef.localdomain" } }) end it "returns nil when given an attribute path that isn't a name or attribute" do - input = { "keys" => {"keys" => "values"}, "hi" => "ho", "id" => "sample-data-bag-item" } + input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } non_existing_path = "nope.nada.nothingtoseehere" @ui.config[:attribute] = non_existing_path expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { non_existing_path => nil } }) @@ -420,10 +420,10 @@ EOM describe "with --with-uri" do it "should return the URIs" do response = { - "cookbook_name"=>{ + "cookbook_name" => { "1.0.0" => "http://url/cookbooks/1.0.0", "2.0.0" => "http://url/cookbooks/2.0.0", - "3.0.0" => "http://url/cookbooks/3.0.0"} + "3.0.0" => "http://url/cookbooks/3.0.0" } } @ui.config[:with_uri] = true expect(@ui.format_cookbook_list_for_display(@item)).to eq(response) @@ -460,8 +460,8 @@ EOM end describe "confirm" do - let(:stdout) {StringIO.new} - let(:output) {stdout.string} + let(:stdout) { StringIO.new } + let(:output) { stdout.string } let(:question) { "monkeys rule" } let(:answer) { "y" } diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb index 9356974735..b852c30401 100644 --- a/spec/unit/knife/data_bag_create_spec.rb +++ b/spec/unit/knife/data_bag_create_spec.rb @@ -36,7 +36,7 @@ describe Chef::Knife::DataBagCreate do let(:secret) { "abc123SECRET" } - let(:raw_hash) {{ "login_name" => "alphaomega", "id" => item_name }} + let(:raw_hash) { { "login_name" => "alphaomega", "id" => item_name } } let(:config) { {} } @@ -49,7 +49,7 @@ describe Chef::Knife::DataBagCreate do it "tries to create a data bag with an invalid name when given one argument" do knife.name_args = ["invalid&char"] expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName) - expect {knife.run}.to exit_with_code(1) + expect { knife.run }.to exit_with_code(1) end context "when given one argument" do @@ -58,7 +58,7 @@ describe Chef::Knife::DataBagCreate do end it "creates a data bag" do - expect(rest).to receive(:post).with("data", {"name" => bag_name}) + expect(rest).to receive(:post).with("data", { "name" => bag_name }) expect(knife.ui).to receive(:info).with("Created data_bag[#{bag_name}]") knife.run @@ -75,7 +75,7 @@ describe Chef::Knife::DataBagCreate do it "creates a data bag item" do expect(knife).to receive(:create_object).and_yield(raw_hash) expect(knife).to receive(:encryption_secret_provided?).and_return(false) - expect(rest).to receive(:post).with("data", {"name" => bag_name}).ordered + expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered knife.run @@ -99,7 +99,7 @@ describe Chef::Knife::DataBagCreate do .to receive(:encrypt_data_bag_item) .with(raw_hash, secret) .and_return(encoded_data) - expect(rest).to receive(:post).with("data", {"name" => bag_name}).ordered + expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered knife.run diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb index 42558c5cbd..1001e68ce4 100644 --- a/spec/unit/knife/data_bag_edit_spec.rb +++ b/spec/unit/knife/data_bag_edit_spec.rb @@ -33,9 +33,9 @@ describe Chef::Knife::DataBagEdit do k end - let(:raw_hash) { {"login_name" => "alphaomega", "id" => "item_name"} } - let(:db) { Chef::DataBagItem.from_hash(raw_hash)} - let(:raw_edited_hash) { {"login_name" => "rho", "id" => "item_name", "new_key" => "new_value"} } + let(:raw_hash) { { "login_name" => "alphaomega", "id" => "item_name" } } + let(:db) { Chef::DataBagItem.from_hash(raw_hash) } + let(:raw_edited_hash) { { "login_name" => "rho", "id" => "item_name", "new_key" => "new_value" } } let(:rest) { double("Chef::ServerAPI") } let(:stdout) { StringIO.new } @@ -65,7 +65,7 @@ describe Chef::Knife::DataBagEdit do it "requires data bag and item arguments" do knife.name_args = [] expect(stdout).to receive(:puts).twice.with(anything) - expect {knife.run}.to exit_with_code(1) + expect { knife.run }.to exit_with_code(1) expect(stdout.string).to eq("") end @@ -74,7 +74,7 @@ describe Chef::Knife::DataBagEdit do end context "when config[:print_after] is set" do - let(:config) { {:print_after => true} } + let(:config) { { :print_after => true } } before do expect(knife.ui).to receive(:output).with(raw_edited_hash) end @@ -121,7 +121,7 @@ describe Chef::Knife::DataBagEdit do expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(false) expect(knife.ui).to receive(:fatal).with("You cannot edit an encrypted data bag without providing the secret.") - expect {knife.run}.to exit_with_code(1) + expect { knife.run }.to exit_with_code(1) end end diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb index 4a31c480c0..0b6f389e87 100644 --- a/spec/unit/knife/data_bag_from_file_spec.rb +++ b/spec/unit/knife/data_bag_from_file_spec.rb @@ -75,7 +75,7 @@ describe Chef::Knife::DataBagFromFile do let(:plain_data) { { "id" => "item_name", "greeting" => "hello", - "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true }}, + "nested" => { "a1" => [1, 2, 3], "a2" => { "b1" => true } }, } } let(:enc_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret) } @@ -164,7 +164,7 @@ describe Chef::Knife::DataBagFromFile do describe "command line parsing" do it "prints help if given no arguments" do knife.name_args = [bag_name] - expect {knife.run}.to exit_with_code(1) + expect { knife.run }.to exit_with_code(1) expect(stdout.string).to start_with("knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)") end end diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb index 489949a0e9..4637e34ba1 100644 --- a/spec/unit/knife/data_bag_show_spec.rb +++ b/spec/unit/knife/data_bag_show_spec.rb @@ -45,10 +45,10 @@ 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(: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_contents) { { "id" => "id", "baz" => "http://localhost:4000/data/bag_o_data/baz", + "qux" => "http://localhost:4000/data/bag_o_data/qux" } } + 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) } let(:enc_data_bag) { Chef::EncryptedDataBagItem.new(enc_hash, secret) } @@ -56,7 +56,7 @@ describe Chef::Knife::DataBagShow do # # let(:raw_hash) {{ "login_name" => "alphaomega", "id" => item_name }} # - let(:config) { {format: "json"} } + let(:config) { { format: "json" } } context "Data bag to show is encrypted" do before do @@ -116,7 +116,7 @@ qux: http://localhost:4000/data/bag_o_data/qux} it "raises an error when no @name_args are provided" do knife.name_args = [] - expect {knife.run}.to exit_with_code(1) + expect { knife.run }.to exit_with_code(1) expect(stdout.string).to start_with("knife data bag show BAG [ITEM] (options)") end diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb index 5d4a71d3a4..7a341192be 100644 --- a/spec/unit/knife/environment_compare_spec.rb +++ b/spec/unit/knife/environment_compare_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::EnvironmentCompare do before(:each) do @knife = Chef::Knife::EnvironmentCompare.new - + @environments = { "cita" => "http://localhost:4000/environments/cita", "citm" => "http://localhost:4000/environments/citm", @@ -33,10 +33,10 @@ describe Chef::Knife::EnvironmentCompare do "cita" => { "foo" => "= 1.0.1", "bar" => "= 0.0.4" }, "citm" => { "foo" => "= 1.0.1", "bar" => "= 0.0.2" }, } - + allow(@knife).to receive(:constraint_list).and_return(@constraints) - @cookbooks = { "foo"=>"= 1.0.1", "bar"=>"= 0.0.1" } + @cookbooks = { "foo" => "= 1.0.1", "bar" => "= 0.0.1" } allow(@knife).to receive(:cookbook_list).and_return(@cookbooks) @@ -46,10 +46,10 @@ describe Chef::Knife::EnvironmentCompare do @base_url = "https://server.example.com/cookbooks" @cookbook_data = {} @cookbook_names.each do |item| - @cookbook_data[item] = {"url" => "#{@base_url}/#{item}", - "versions" => [{"version" => "1.0.1", - "url" => "#{@base_url}/#{item}/1.0.1"}]} - end + @cookbook_data[item] = { "url" => "#{@base_url}/#{item}", + "versions" => [{ "version" => "1.0.1", + "url" => "#{@base_url}/#{item}/1.0.1" }] } + end allow(@rest_double).to receive(:get).with("/cookbooks?num_versions=1").and_return(@cookbook_data) @@ -65,7 +65,7 @@ describe Chef::Knife::EnvironmentCompare do expect(@stdout.string).to match /#{item}/ and expect(@stdout.string.lines.count).to be 4 end end - + it "should display 4 number of lines" do @knife.config[:format] = "summary" @knife.run @@ -90,7 +90,7 @@ describe Chef::Knife::EnvironmentCompare do expect(@stdout.string.lines.count).to be 3 end end - + describe "with -a or --all" do it "should display all cookbooks" do @knife.config[:format] = "summary" diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb index afabc0051f..4505da3637 100644 --- a/spec/unit/knife/environment_from_file_spec.rb +++ b/spec/unit/knife/environment_from_file_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::EnvironmentFromFile do @environment = Chef::Environment.new @environment.name("spec") @environment.description("runs the unit tests") - @environment.cookbook_versions({"apt" => "= 1.2.3"}) + @environment.cookbook_versions({ "apt" => "= 1.2.3" }) allow(@environment).to receive(:save).and_return true allow(@knife.loader).to receive(:load_from).and_return @environment end @@ -61,7 +61,7 @@ describe Chef::Knife::EnvironmentFromFile do allow(File).to receive(:expand_path).with("./environments/").and_return("/tmp/environments") allow(Dir).to receive(:glob).with("/tmp/environments/*.{json,rb}").and_return(["spec.rb", "apple.rb"]) @knife.name_args = [] - allow(@knife).to receive(:config).and_return({:all => true}) + allow(@knife).to receive(:config).and_return({ :all => true }) expect(@environment).to receive(:save).twice @knife.run end diff --git a/spec/unit/knife/environment_list_spec.rb b/spec/unit/knife/environment_list_spec.rb index 2ee11e91dc..636b32273e 100644 --- a/spec/unit/knife/environment_list_spec.rb +++ b/spec/unit/knife/environment_list_spec.rb @@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentList do end it "should print the environment names in a sorted list" do - names = @environments.keys.sort { |a,b| a <=> b } + names = @environments.keys.sort { |a, b| a <=> b } expect(@knife).to receive(:output).with(names) @knife.run end diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb index 1e9803c4b7..97a3a69155 100644 --- a/spec/unit/knife/index_rebuild_spec.rb +++ b/spec/unit/knife/index_rebuild_spec.rb @@ -20,8 +20,8 @@ require "spec_helper" describe Chef::Knife::IndexRebuild do - let(:knife){Chef::Knife::IndexRebuild.new} - let(:rest_client){double(Chef::ServerAPI)} + let(:knife) { Chef::Knife::IndexRebuild.new } + let(:rest_client) { double(Chef::ServerAPI) } let(:stub_rest!) do expect(knife).to receive(:rest).and_return(rest_client) @@ -49,14 +49,14 @@ describe Chef::Knife::IndexRebuild do end context "against a Chef 11 server" do - let(:api_header_value){"flavor=osc;version=11.0.0;erchef=1.2.3"} + let(:api_header_value) { "flavor=osc;version=11.0.0;erchef=1.2.3" } it "retrieves API information" do - expect(knife.grab_api_info).to eq({"flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3"}) + expect(knife.grab_api_info).to eq({ "flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3" }) end end # Chef 11 context "against a Chef 10 server" do - let(:api_header_value){nil} + let(:api_header_value) { nil } it "finds no API information" do expect(knife.grab_api_info).to eq({}) end @@ -66,11 +66,11 @@ describe Chef::Knife::IndexRebuild do context "#unsupported_version?" do context "with Chef 11 API metadata" do it "is unsupported" do - expect(knife.unsupported_version?({"version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy + expect(knife.unsupported_version?({ "version" => "11.0.0", "flavor" => "osc", "erchef" => "1.2.3" })).to be_truthy end it "only truly relies on the version being non-nil" do - expect(knife.unsupported_version?({"version" => "1", "flavor" => "osc", "erchef" => "1.2.3"})).to be_truthy + expect(knife.unsupported_version?({ "version" => "1", "flavor" => "osc", "erchef" => "1.2.3" })).to be_truthy end end @@ -91,7 +91,7 @@ describe Chef::Knife::IndexRebuild do context "against a Chef 11 server" do let(:api_info) do - {"flavor" => "osc", + { "flavor" => "osc", "version" => "11.0.0", "erchef" => "1.2.3", } @@ -107,7 +107,7 @@ describe Chef::Knife::IndexRebuild do end context "against a Chef 10 server" do - let(:api_info){ {} } + let(:api_info) { {} } let(:server_specific_stubs!) do stub_rest! expect(rest_client).to receive(:post).with("/search/reindex", {}).and_return("representative output") @@ -123,6 +123,3 @@ describe Chef::Knife::IndexRebuild do end end - - - diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb index 1b9e551df7..1647b14dc2 100644 --- a/spec/unit/knife/key_create_spec.rb +++ b/spec/unit/knife/key_create_spec.rb @@ -95,7 +95,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo context "when public_key and key_name weren't passed" do it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do - expect{ key_create_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_create_object.public_key_or_key_name_error_msg) + expect { key_create_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_create_object.public_key_or_key_name_error_msg) end end @@ -221,4 +221,3 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo end end end - diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb index 0f09ec9c3d..3da5a9762a 100644 --- a/spec/unit/knife/key_delete_spec.rb +++ b/spec/unit/knife/key_delete_spec.rb @@ -45,8 +45,8 @@ describe "key delete commands that inherit knife" do context "when the service object is called" do it "creates a new instance of Chef::Knife::KeyDelete with the correct args" do expect(Chef::Knife::KeyDelete).to receive(:new). - with("charmander-key", "charmander", command.actor_field_name, command.ui). - and_return(service_object) + with("charmander-key", "charmander", command.actor_field_name, command.ui). + and_return(service_object) command.service_object end end # when the service object is called @@ -117,7 +117,6 @@ describe Chef::Knife::KeyDelete do end end # when the command is run - end # key delete run command context "when actor_field_name is 'user'" do @@ -132,4 +131,3 @@ describe Chef::Knife::KeyDelete do end end end - diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb index 3a9689d4d1..0fc7208139 100644 --- a/spec/unit/knife/key_edit_spec.rb +++ b/spec/unit/knife/key_edit_spec.rb @@ -45,8 +45,8 @@ describe "key edit commands that inherit knife" do context "when the service object is called" do it "creates a new instance of Chef::Knife::KeyEdit with the correct args" do expect(Chef::Knife::KeyEdit).to receive(:new). - with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config). - and_return(service_object) + with("charmander-key", "charmander", command.actor_field_name, command.ui, command.config). + and_return(service_object) command.service_object end end # when the service object is called @@ -114,7 +114,6 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo allow(key_edit_object).to receive(:display_info) end - context "when public_key and create_key are passed" do before do key_edit_object.config[:public_key] = "public_key_path" @@ -122,7 +121,7 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo end it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do - expect{ key_edit_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_edit_object.public_key_and_create_key_error_msg) + expect { key_edit_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_edit_object.public_key_and_create_key_error_msg) end end @@ -249,8 +248,6 @@ Tfuc9dUYsFjptWYrV6pfEQ+bgo1OGBXORBFcFL+2D7u9JYquKrMgosznHoEkQNLo end # when the command is run - - end # key edit run command context "when actor_field_name is 'user'" do diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb index 989deac76e..2d4f0a07bb 100644 --- a/spec/unit/knife/key_list_spec.rb +++ b/spec/unit/knife/key_list_spec.rb @@ -98,7 +98,7 @@ describe Chef::Knife::KeyList do end it "raises a Chef::Exceptions::KeyCommandInputError with the proper error message" do - expect{ key_list_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_list_object.expired_and_non_expired_msg) + expect { key_list_object.run }.to raise_error(Chef::Exceptions::KeyCommandInputError, key_list_object.expired_and_non_expired_msg) end end @@ -193,9 +193,9 @@ describe Chef::Knife::KeyList do let(:list_method) { :list_by_user } let(:http_response) { [ - {"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}, + { "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 @@ -206,9 +206,9 @@ describe Chef::Knife::KeyList do let(:list_method) { :list_by_client } let(:http_response) { [ - {"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}, + { "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 diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb index 0681ad8b72..c161efbe0d 100644 --- a/spec/unit/knife/key_show_spec.rb +++ b/spec/unit/knife/key_show_spec.rb @@ -45,8 +45,8 @@ describe "key show commands that inherit knife" do context "when the service object is called" do it "creates a new instance of Chef::Knife::KeyShow with the correct args" do expect(Chef::Knife::KeyShow).to receive(:new). - with("charmander-key", "charmander", command.load_method, command.ui). - and_return(service_object) + with("charmander-key", "charmander", command.load_method, command.ui). + and_return(service_object) command.service_object end end # when the service object is called diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb index 8744787ef6..2a3563e563 100644 --- a/spec/unit/knife/node_bulk_delete_spec.rb +++ b/spec/unit/knife/node_bulk_delete_spec.rb @@ -22,7 +22,7 @@ describe Chef::Knife::NodeBulkDelete do before(:each) do Chef::Log.logger = Logger.new(StringIO.new) - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeBulkDelete.new @knife.name_args = ["."] @stdout = StringIO.new @@ -37,14 +37,14 @@ describe Chef::Knife::NodeBulkDelete do describe "when creating the list of nodes" do it "fetches the node list" do expected = @nodes.inject({}) do |inflatedish, (name, uri)| - inflatedish[name] = Chef::Node.new.tap {|n| n.name(name)} + inflatedish[name] = Chef::Node.new.tap { |n| n.name(name) } inflatedish end expect(Chef::Node).to receive(:list).and_return(@nodes) # I hate not having == defined for anything :( actual = @knife.all_nodes expect(actual.keys).to match_array(expected.keys) - expect(actual.values.map {|n| n.name }).to match_array(%w{adam brent jacob}) + expect(actual.values.map { |n| n.name }).to match_array(%w{adam brent jacob}) end end @@ -92,6 +92,3 @@ describe Chef::Knife::NodeBulkDelete do end end - - - diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb index da4c44a651..e2cda8751f 100644 --- a/spec/unit/knife/node_delete_spec.rb +++ b/spec/unit/knife/node_delete_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeDelete do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeDelete.new @knife.config = { :print_after => nil diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb index 2cf6633574..dedb5c949d 100644 --- a/spec/unit/knife/node_edit_spec.rb +++ b/spec/unit/knife/node_edit_spec.rb @@ -27,7 +27,7 @@ describe Chef::Knife::NodeEdit do end before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeEdit.new @knife.config = { :editor => "cat", @@ -46,10 +46,10 @@ describe Chef::Knife::NodeEdit do describe "after loading the node" do before do allow(@knife).to receive(:node).and_return(@node) - @node.automatic_attrs = {:go => :away} - @node.default_attrs = {:hide => :me} - @node.override_attrs = {:dont => :show} - @node.normal_attrs = {:do_show => :these} + @node.automatic_attrs = { :go => :away } + @node.default_attrs = { :hide => :me } + @node.override_attrs = { :dont => :show } + @node.normal_attrs = { :do_show => :these } @node.chef_environment("prod") @node.run_list("recipe[foo]") end @@ -59,7 +59,7 @@ describe Chef::Knife::NodeEdit do expect(actual).not_to have_key("automatic") expect(actual).not_to have_key("override") expect(actual).not_to have_key("default") - expect(actual["normal"]).to eq({"do_show" => "these"}) + expect(actual["normal"]).to eq({ "do_show" => "these" }) expect(actual["run_list"]).to eq(["recipe[foo]"]) expect(actual["chef_environment"]).to eq("prod") end @@ -68,10 +68,10 @@ describe Chef::Knife::NodeEdit do @knife.config[:all_attributes] = true actual = deserialized_json_view - expect(actual["automatic"]).to eq({"go" => "away"}) - expect(actual["override"]).to eq({"dont" => "show"}) - expect(actual["default"]).to eq({"hide" => "me"}) - expect(actual["normal"]).to eq({"do_show" => "these"}) + expect(actual["automatic"]).to eq({ "go" => "away" }) + expect(actual["override"]).to eq({ "dont" => "show" }) + expect(actual["default"]).to eq({ "hide" => "me" }) + expect(actual["normal"]).to eq({ "do_show" => "these" }) expect(actual["run_list"]).to eq(["recipe[foo]"]) expect(actual["chef_environment"]).to eq("prod") end @@ -101,15 +101,14 @@ describe Chef::Knife::NodeEdit do it "raises an exception when editing is disabled" do @knife.config[:disable_editing] = true - expect{ subject }.to raise_error(SystemExit) + expect { subject }.to raise_error(SystemExit) end it "raises an exception when the editor is not set" do @knife.config[:editor] = nil - expect{ subject }.to raise_error(SystemExit) + expect { subject }.to raise_error(SystemExit) end end end - diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb index 7fba0cf841..13dd3762a2 100644 --- a/spec/unit/knife/node_environment_set_spec.rb +++ b/spec/unit/knife/node_environment_set_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeEnvironmentSet do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeEnvironmentSet.new @knife.name_args = [ "adam", "bar" ] allow(@knife).to receive(:output).and_return(true) diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb index 728483e22d..89b2b8156f 100644 --- a/spec/unit/knife/node_from_file_spec.rb +++ b/spec/unit/knife/node_from_file_spec.rb @@ -22,7 +22,7 @@ Chef::Knife::NodeFromFile.load_deps describe Chef::Knife::NodeFromFile do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeFromFile.new @knife.config = { :print_after => nil diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb index 3112e0b804..ab17a45795 100644 --- a/spec/unit/knife/node_list_spec.rb +++ b/spec/unit/knife/node_list_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeList do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" Chef::Config[:environment] = nil # reset this value each time, as it is not reloaded @knife = Chef::Knife::NodeList.new allow(@knife).to receive(:output).and_return(true) @@ -60,4 +60,3 @@ describe Chef::Knife::NodeList do end end end - diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb index 6bdaee6915..eb897c146b 100644 --- a/spec/unit/knife/node_run_list_add_spec.rb +++ b/spec/unit/knife/node_run_list_add_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeRunListAdd do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeRunListAdd.new @knife.config = { :after => nil @@ -143,6 +143,3 @@ describe Chef::Knife::NodeRunListAdd do end end end - - - diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb index 54f8625898..e741f513eb 100644 --- a/spec/unit/knife/node_run_list_remove_spec.rb +++ b/spec/unit/knife/node_run_list_remove_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeRunListRemove do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeRunListRemove.new @knife.config[:print_after] = nil @knife.name_args = [ "adam", "role[monkey]" ] diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb index 11d3be7e84..1bbaa7d9a5 100644 --- a/spec/unit/knife/node_run_list_set_spec.rb +++ b/spec/unit/knife/node_run_list_set_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::NodeRunListSet do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeRunListSet.new @knife.config = {} @knife.name_args = [ "adam", "role[monkey]" ] diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb index a69c133a0e..9202998fb9 100644 --- a/spec/unit/knife/raw_spec.rb +++ b/spec/unit/knife/raw_spec.rb @@ -36,7 +36,7 @@ describe Chef::Knife::Raw do knife.config[:proxy_auth] = true expect(rest).to receive(:request).with(:GET, "/nodes", { "Content-Type" => "application/json", - "x-ops-request-source" => "web"}, false) + "x-ops-request-source" => "web" }, false) knife.run end end diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb index 75edab8aa9..9a4a1a0bc7 100644 --- a/spec/unit/knife/role_bulk_delete_spec.rb +++ b/spec/unit/knife/role_bulk_delete_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::RoleBulkDelete do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleBulkDelete.new @knife.config = { :print_after => nil diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb index 765cec7882..d414e5a18d 100644 --- a/spec/unit/knife/role_create_spec.rb +++ b/spec/unit/knife/role_create_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::RoleCreate do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleCreate.new @knife.config = { :description => nil diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb index 3251ddd81c..cc65674a08 100644 --- a/spec/unit/knife/role_delete_spec.rb +++ b/spec/unit/knife/role_delete_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::RoleDelete do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleDelete.new @knife.config = { :print_after => nil diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb index 5f4ed1eb8e..71d6980670 100644 --- a/spec/unit/knife/role_edit_spec.rb +++ b/spec/unit/knife/role_edit_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::RoleEdit do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleEdit.new @knife.config[:print_after] = nil @knife.name_args = [ "adam" ] @@ -75,5 +75,3 @@ describe Chef::Knife::RoleEdit do end end end - - diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb index 0831abd845..fe4cb6d057 100644 --- a/spec/unit/knife/role_env_run_list_add_spec.rb +++ b/spec/unit/knife/role_env_run_list_add_spec.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ describe Chef::Knife::RoleEnvRunListAdd do } @knife.name_args = [ "will", "QA", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new() allow(@role).to receive(:save).and_return(true) allow(Chef::Role).to receive(:load).and_return(@role) end @@ -180,7 +180,7 @@ describe Chef::Knife::RoleEnvRunListAdd do expect(@role.run_list[1]).to be_nil end end - + describe "with more than one command" do it "should be able to the environment run list by running multiple knife commands" do @knife.name_args = [ "will", "QA", "role[blue]," ] diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb index 831a23b71b..1fb2f1f1c7 100644 --- a/spec/unit/knife/role_env_run_list_clear_spec.rb +++ b/spec/unit/knife/role_env_run_list_clear_spec.rb @@ -21,8 +21,8 @@ require "spec_helper" describe Chef::Knife::RoleEnvRunListClear do before(:each) do - Chef::Config[:role_name] = "will" - Chef::Config[:env_name] = "QA" + Chef::Config[:role_name] = "will" + Chef::Config[:env_name] = "QA" @setup = Chef::Knife::RoleEnvRunListAdd.new @setup.name_args = [ "will", "QA", "role[monkey]", "role[person]" ] @@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListClear do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -57,44 +54,41 @@ describe Chef::Knife::RoleEnvRunListClear do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list_for("QA")[0]).to be_nil - expect(@role.run_list[0]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list_for("QA")[0]).to be_nil + expect(@role.run_list[0]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "should clear an environmental run list of roles and recipes" do - it "should remove the items from the run list" do - @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will", "QA" ] - @knife.run - expect(@role.run_list_for("QA")[0]).to be_nil - expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") - expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") - expect(@role.run_list_for("PRD")[3]).to eq("role[person]") - expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") - expect(@role.run_list_for("PRD")[5]).to eq("role[town]") - end - end + describe "should clear an environmental run list of roles and recipes" do + it "should remove the items from the run list" do + @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will", "QA" ] + @knife.run + expect(@role.run_list_for("QA")[0]).to be_nil + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") + end + end end end - - - diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb index 39f4a78e28..180dbf1d43 100644 --- a/spec/unit/knife/role_env_run_list_remove_spec.rb +++ b/spec/unit/knife/role_env_run_list_remove_spec.rb @@ -21,8 +21,8 @@ require "spec_helper" describe Chef::Knife::RoleEnvRunListRemove do before(:each) do - Chef::Config[:role_name] = "will" - Chef::Config[:env_name] = "QA" + Chef::Config[:role_name] = "will" + Chef::Config[:env_name] = "QA" @setup = Chef::Knife::RoleEnvRunListAdd.new @setup.name_args = [ "will", "QA", "role[monkey]", "role[person]" ] @@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListRemove do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -57,52 +54,49 @@ describe Chef::Knife::RoleEnvRunListRemove do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list_for("QA")[0]).not_to eq("role[monkey]") - expect(@role.run_list_for("QA")[0]).to eq("role[person]") - expect(@role.run_list[0]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list_for("QA")[0]).not_to eq("role[monkey]") + expect(@role.run_list_for("QA")[0]).to eq("role[person]") + expect(@role.run_list[0]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "run with a list of roles and recipes" do - it "should remove the items from the run list" do - @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will", "QA", "role[monkey]" ] - @knife.run - @knife.name_args = [ "will", "QA", "recipe[duck::type]" ] - @knife.run - expect(@role.run_list_for("QA")).not_to include("role[monkey]") - expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") - expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list_for("QA")[1]).to eq("role[person]") - expect(@role.run_list_for("QA")[2]).to eq("role[bird]") - expect(@role.run_list_for("QA")[3]).to eq("role[town]") - expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") - expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") - expect(@role.run_list_for("PRD")[3]).to eq("role[person]") - expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") - expect(@role.run_list_for("PRD")[5]).to eq("role[town]") - end - end + describe "run with a list of roles and recipes" do + it "should remove the items from the run list" do + @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will", "QA", "role[monkey]" ] + @knife.run + @knife.name_args = [ "will", "QA", "recipe[duck::type]" ] + @knife.run + expect(@role.run_list_for("QA")).not_to include("role[monkey]") + expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") + expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("QA")[1]).to eq("role[person]") + expect(@role.run_list_for("QA")[2]).to eq("role[bird]") + expect(@role.run_list_for("QA")[3]).to eq("role[town]") + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") + end + end end end - - - diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb index 537ede29ce..fcfbe99e7c 100644 --- a/spec/unit/knife/role_env_run_list_replace_spec.rb +++ b/spec/unit/knife/role_env_run_list_replace_spec.rb @@ -21,8 +21,8 @@ require "spec_helper" describe Chef::Knife::RoleEnvRunListReplace do before(:each) do - Chef::Config[:role_name] = "will" - Chef::Config[:env_name] = "QA" + Chef::Config[:role_name] = "will" + Chef::Config[:env_name] = "QA" @setup = Chef::Knife::RoleEnvRunListAdd.new @setup.name_args = [ "will", "QA", "role[monkey]", "role[dude]", "role[fixer]" ] @@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListReplace do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -57,52 +54,52 @@ describe Chef::Knife::RoleEnvRunListReplace do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list_for("QA")[1]).not_to eq("role[dude]") - expect(@role.run_list_for("QA")[1]).to eq("role[person]") - expect(@role.run_list[0]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list_for("QA")[1]).not_to eq("role[dude]") + expect(@role.run_list_for("QA")[1]).to eq("role[person]") + expect(@role.run_list[0]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "run with a list of roles and recipes" do - it "should replace the items from the run list" do - @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ] - @knife.run - @knife.name_args = [ "will", "QA", "recipe[duck::type]", "recipe[duck::mallard]" ] - @knife.run - expect(@role.run_list_for("QA")).not_to include("role[monkey]") - expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") - expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list_for("QA")[1]).to eq("role[gibbon]") - expect(@role.run_list_for("QA")[2]).to eq("recipe[duck::mallard]") - expect(@role.run_list_for("QA")[3]).to eq("role[person]") - expect(@role.run_list_for("QA")[4]).to eq("role[bird]") - expect(@role.run_list_for("QA")[5]).to eq("role[town]") - expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") - expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") - expect(@role.run_list_for("PRD")[3]).to eq("role[person]") - expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") - expect(@role.run_list_for("PRD")[5]).to eq("role[town]") - expect(@role.run_list[0]).to be_nil - end - end + describe "run with a list of roles and recipes" do + it "should replace the items from the run list" do + @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ] + @knife.run + @knife.name_args = [ "will", "QA", "recipe[duck::type]", "recipe[duck::mallard]" ] + @knife.run + expect(@role.run_list_for("QA")).not_to include("role[monkey]") + expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") + expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("QA")[1]).to eq("role[gibbon]") + expect(@role.run_list_for("QA")[2]).to eq("recipe[duck::mallard]") + expect(@role.run_list_for("QA")[3]).to eq("role[person]") + expect(@role.run_list_for("QA")[4]).to eq("role[bird]") + expect(@role.run_list_for("QA")[5]).to eq("role[town]") + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") + expect(@role.run_list[0]).to be_nil + end + end end end diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb index 83a665c34f..6fb187447d 100644 --- a/spec/unit/knife/role_env_run_list_set_spec.rb +++ b/spec/unit/knife/role_env_run_list_set_spec.rb @@ -21,8 +21,8 @@ require "spec_helper" describe Chef::Knife::RoleEnvRunListSet do before(:each) do - Chef::Config[:role_name] = "will" - Chef::Config[:env_name] = "QA" + Chef::Config[:role_name] = "will" + Chef::Config[:env_name] = "QA" @setup = Chef::Knife::RoleEnvRunListAdd.new @setup.name_args = [ "will", "QA", "role[monkey]", "role[person]", "role[bucket]" ] @@ -42,11 +42,8 @@ describe Chef::Knife::RoleEnvRunListSet do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -60,8 +57,8 @@ describe Chef::Knife::RoleEnvRunListSet do it "should replace all the items in the runlist with what is specified" do @setup.run @knife.run - expect(@role.run_list_for("QA")[0]).to eq("role[owen]") - expect(@role.run_list_for("QA")[1]).to eq("role[mauntel]") + expect(@role.run_list_for("QA")[0]).to eq("role[owen]") + expect(@role.run_list_for("QA")[1]).to eq("role[mauntel]") expect(@role.run_list_for("QA")[2]).to be_nil expect(@role.run_list[0]).to be_nil end diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb index 1660026b1a..741ff99741 100644 --- a/spec/unit/knife/role_from_file_spec.rb +++ b/spec/unit/knife/role_from_file_spec.rb @@ -22,7 +22,7 @@ Chef::Knife::RoleFromFile.load_deps describe Chef::Knife::RoleFromFile do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleFromFile.new @knife.config = { :print_after => nil diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb index daf2645aef..bfbba30288 100644 --- a/spec/unit/knife/role_list_spec.rb +++ b/spec/unit/knife/role_list_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::RoleList do before(:each) do - Chef::Config[:node_name] = "webmonkey.example.com" + Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::RoleList.new allow(@knife).to receive(:output).and_return(true) @list = { @@ -52,5 +52,3 @@ describe Chef::Knife::RoleList do end end end - - diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb index ac5202da22..419fbdfedb 100644 --- a/spec/unit/knife/role_run_list_add_spec.rb +++ b/spec/unit/knife/role_run_list_add_spec.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ describe Chef::Knife::RoleRunListAdd do } @knife.name_args = [ "will", "role[monkey]" ] allow(@knife).to receive(:output).and_return(true) - @role = Chef::Role.new() + @role = Chef::Role.new() allow(@role).to receive(:save).and_return(true) allow(Chef::Role).to receive(:load).and_return(@role) end @@ -162,7 +162,7 @@ describe Chef::Knife::RoleRunListAdd do expect(@role.run_list[2]).to be_nil end end - + describe "with more than one command" do it "should be able to the environment run list by running multiple knife commands" do @knife.name_args = [ "will", "role[blue]," ] diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb index 5e1a388c75..61dfc8fa89 100644 --- a/spec/unit/knife/role_run_list_clear_spec.rb +++ b/spec/unit/knife/role_run_list_clear_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::RoleRunListClear do before(:each) do - Chef::Config[:role_name] = "will" + Chef::Config[:role_name] = "will" @setup = Chef::Knife::RoleRunListAdd.new @setup.name_args = [ "will", "role[monkey]", "role[person]" ] @@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListClear do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -56,35 +53,32 @@ describe Chef::Knife::RoleRunListClear do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list[0]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list[0]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "should clear an environmental run list of roles and recipes" do - it "should remove the items from the run list" do - @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will" ] - @knife.run - expect(@role.run_list[0]).to be_nil - end - end + describe "should clear an environmental run list of roles and recipes" do + it "should remove the items from the run list" do + @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will" ] + @knife.run + expect(@role.run_list[0]).to be_nil + end + end end end - - - diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb index f3cc38e616..704c3d3cb4 100644 --- a/spec/unit/knife/role_run_list_remove_spec.rb +++ b/spec/unit/knife/role_run_list_remove_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::RoleRunListRemove do before(:each) do - Chef::Config[:role_name] = "will" + Chef::Config[:role_name] = "will" @setup = Chef::Knife::RoleRunListAdd.new @setup.name_args = [ "will", "role[monkey]", "role[person]" ] @@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListRemove do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -56,43 +53,40 @@ describe Chef::Knife::RoleRunListRemove do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list[0]).to eq("role[person]") - expect(@role.run_list[1]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list[0]).to eq("role[person]") + expect(@role.run_list[1]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "run with a list of roles and recipes" do - it "should remove the items from the run list" do - @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will", "role[monkey]" ] - @knife.run - @knife.name_args = [ "will", "recipe[duck::type]" ] - @knife.run - expect(@role.run_list).not_to include("role[monkey]") - expect(@role.run_list).not_to include("recipe[duck::type]") - expect(@role.run_list[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list[1]).to eq("role[person]") - expect(@role.run_list[2]).to eq("role[bird]") - expect(@role.run_list[3]).to eq("role[town]") - end - end + describe "run with a list of roles and recipes" do + it "should remove the items from the run list" do + @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will", "role[monkey]" ] + @knife.run + @knife.name_args = [ "will", "recipe[duck::type]" ] + @knife.run + expect(@role.run_list).not_to include("role[monkey]") + expect(@role.run_list).not_to include("recipe[duck::type]") + expect(@role.run_list[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list[1]).to eq("role[person]") + expect(@role.run_list[2]).to eq("role[bird]") + expect(@role.run_list[3]).to eq("role[town]") + end + end end end - - - diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb index 74f648a372..91e4993630 100644 --- a/spec/unit/knife/role_run_list_replace_spec.rb +++ b/spec/unit/knife/role_run_list_replace_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::RoleRunListReplace do before(:each) do - Chef::Config[:role_name] = "will" + Chef::Config[:role_name] = "will" @setup = Chef::Knife::RoleRunListAdd.new @setup.name_args = [ "will", "role[monkey]", "role[dude]", "role[fixer]" ] @@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListReplace do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -56,46 +53,46 @@ describe Chef::Knife::RoleRunListReplace do @knife.run end - it "should remove the item from the run list" do - @setup.run - @knife.run - expect(@role.run_list[0]).to eq("role[monkey]") - expect(@role.run_list[1]).not_to eq("role[dude]") - expect(@role.run_list[1]).to eq("role[person]") - expect(@role.run_list[2]).to eq("role[fixer]") - expect(@role.run_list[3]).to be_nil - end + it "should remove the item from the run list" do + @setup.run + @knife.run + expect(@role.run_list[0]).to eq("role[monkey]") + expect(@role.run_list[1]).not_to eq("role[dude]") + expect(@role.run_list[1]).to eq("role[person]") + expect(@role.run_list[2]).to eq("role[fixer]") + expect(@role.run_list[3]).to be_nil + end - it "should save the node" do - expect(@role).to receive(:save).and_return(true) - @knife.run - end + it "should save the node" do + expect(@role).to receive(:save).and_return(true) + @knife.run + end - it "should print the run list" do - expect(@knife).to receive(:output).and_return(true) - @knife.config[:print_after] = true - @setup.run - @knife.run - end + it "should print the run list" do + expect(@knife).to receive(:output).and_return(true) + @knife.config[:print_after] = true + @setup.run + @knife.run + end - describe "run with a list of roles and recipes" do - it "should replace the items from the run list" do - @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] - @setup.run - @knife.name_args = [ "will", "role[monkey]", "role[gibbon]" ] - @knife.run - @knife.name_args = [ "will", "recipe[duck::type]", "recipe[duck::mallard]" ] - @knife.run - expect(@role.run_list).not_to include("role[monkey]") - expect(@role.run_list).not_to include("recipe[duck::type]") - expect(@role.run_list[0]).to eq("recipe[orange::chicken]") - expect(@role.run_list[1]).to eq("role[gibbon]") - expect(@role.run_list[2]).to eq("recipe[duck::mallard]") - expect(@role.run_list[3]).to eq("role[person]") - expect(@role.run_list[4]).to eq("role[bird]") - expect(@role.run_list[5]).to eq("role[town]") - expect(@role.run_list[6]).to be_nil - end - end + describe "run with a list of roles and recipes" do + it "should replace the items from the run list" do + @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] + @setup.run + @knife.name_args = [ "will", "role[monkey]", "role[gibbon]" ] + @knife.run + @knife.name_args = [ "will", "recipe[duck::type]", "recipe[duck::mallard]" ] + @knife.run + expect(@role.run_list).not_to include("role[monkey]") + expect(@role.run_list).not_to include("recipe[duck::type]") + expect(@role.run_list[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list[1]).to eq("role[gibbon]") + expect(@role.run_list[2]).to eq("recipe[duck::mallard]") + expect(@role.run_list[3]).to eq("role[person]") + expect(@role.run_list[4]).to eq("role[bird]") + expect(@role.run_list[5]).to eq("role[town]") + expect(@role.run_list[6]).to be_nil + end + end end end diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb index 5207f631d4..ad088e5d0f 100644 --- a/spec/unit/knife/role_run_list_set_spec.rb +++ b/spec/unit/knife/role_run_list_set_spec.rb @@ -21,7 +21,7 @@ require "spec_helper" describe Chef::Knife::RoleRunListSet do before(:each) do - Chef::Config[:role_name] = "will" + Chef::Config[:role_name] = "will" @setup = Chef::Knife::RoleRunListAdd.new @setup.name_args = [ "will", "role[monkey]", "role[person]", "role[bucket]" ] @@ -41,11 +41,8 @@ describe Chef::Knife::RoleRunListSet do end - - describe "run" do - # it "should display all the things" do # @knife.run # @role.to_json.should == 'show all the things' @@ -59,8 +56,8 @@ describe Chef::Knife::RoleRunListSet do it "should replace all the items in the runlist with what is specified" do @setup.run @knife.run - expect(@role.run_list[0]).to eq("role[owen]") - expect(@role.run_list[1]).to eq("role[mauntel]") + expect(@role.run_list[0]).to eq("role[owen]") + expect(@role.run_list[1]).to eq("role[mauntel]") expect(@role.run_list[2]).to be_nil end diff --git a/spec/unit/knife/role_show_spec.rb b/spec/unit/knife/role_show_spec.rb index 657c508f10..fe48e2f940 100644 --- a/spec/unit/knife/role_show_spec.rb +++ b/spec/unit/knife/role_show_spec.rb @@ -40,14 +40,14 @@ describe Chef::Knife::RoleShow do knife.config[:format] = "json" stdout = StringIO.new allow(knife.ui).to receive(:stdout).and_return(stdout) - fake_role_contents = {"foo"=>"bar", "baz"=>"qux"} + fake_role_contents = { "foo" => "bar", "baz" => "qux" } expect(Chef::Role).to receive(:load).with("base").and_return(fake_role_contents) knife.run expect(stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n") end context "without a role name" do - let(:role) { } + let(:role) {} it "should print usage and exit when a role name is not provided" do expect(knife).to receive(:show_usage) diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 5fed92ffa5..3a8728515d 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -114,10 +114,10 @@ describe Chef::Knife::Ssh do end it "should raise an error if no host are found" do - configure_query([ ]) - expect(@knife.ui).to receive(:fatal) - expect(@knife).to receive(:exit).with(10) - @knife.configure_session + configure_query([ ]) + expect(@knife.ui).to receive(:fatal) + expect(@knife).to receive(:exit).with(10) + @knife.configure_session end context "when there are some hosts found but they do not have an attribute to connect with" do @@ -170,26 +170,26 @@ describe Chef::Knife::Ssh do expect(@knife.get_ssh_attribute(@node_foo)).to eq("cloud.public_hostname") end - it "should favor to attribute_from_cli over config file and cloud" do + it "should favor to attribute_from_cli over config file and cloud" do @knife.config[:attribute] = "command_line" Chef::Config[:knife][:ssh_attribute] = "config_file" expect( @knife.get_ssh_attribute(@node_foo)).to eq("command_line") end - it "should favor config file over cloud and default" do + it "should favor config file over cloud and default" do Chef::Config[:knife][:ssh_attribute] = "config_file" expect( @knife.get_ssh_attribute(@node_foo)).to eq("config_file") end it "should return fqdn if cloud.hostname is empty" do - expect( @knife.get_ssh_attribute(@node_bar)).to eq("fqdn") + expect( @knife.get_ssh_attribute(@node_bar)).to eq("fqdn") end end describe "#session_from_list" do before :each do @knife.instance_variable_set(:@longest, 0) - ssh_config = {:timeout => 50, :user => "locutus", :port => 23 } + ssh_config = { :timeout => 50, :user => "locutus", :port => 23 } allow(Net::SSH).to receive(:configuration_for).with("the.b.org").and_return(ssh_config) end @@ -211,10 +211,10 @@ describe Chef::Knife::Ssh do describe "#ssh_command" do let(:execution_channel) { double(:execution_channel, :on_data => nil) } - let(:session_channel) { double(:session_channel, :request_pty => nil)} + let(:session_channel) { double(:session_channel, :request_pty => nil) } let(:execution_channel2) { double(:execution_channel, :on_data => nil) } - let(:session_channel2) { double(:session_channel, :request_pty => nil)} + let(:session_channel2) { double(:session_channel, :request_pty => nil) } let(:session) { double(:session, :loop => nil) } @@ -309,14 +309,14 @@ describe Chef::Knife::Ssh do context "when setting ssh_password_ng from knife ssh" do # in this case ssh_password_ng exists, but ssh_password does not - it "should prompt for a password when ssh_passsword_ng is nil" do + it "should prompt for a password when ssh_passsword_ng is nil" do @knife.config[:ssh_password_ng] = nil expect(@knife).to receive(:get_password).and_return("mysekretpassw0rd") @knife.configure_password expect(@knife.config[:ssh_password]).to eq("mysekretpassw0rd") end - it "should set ssh_password to false if ssh_password_ng is false" do + it "should set ssh_password to false if ssh_password_ng is false" do @knife.config[:ssh_password_ng] = false expect(@knife).not_to receive(:get_password) @knife.configure_password @@ -360,14 +360,14 @@ describe Chef::Knife::Ssh do end context "when setting ssh_password_ng from knife ssh" do # in this case ssh_password_ng exists, but ssh_password does not - it "should prompt for a password when ssh_passsword_ng is nil" do + it "should prompt for a password when ssh_passsword_ng is nil" do @knife.config[:ssh_password_ng] = nil expect(@knife).to receive(:get_password).and_return("mysekretpassw0rd") @knife.configure_password expect(@knife.config[:ssh_password]).to eq("mysekretpassw0rd") end - it "should set ssh_password to the configured knife.rb value if ssh_password_ng is false" do + it "should set ssh_password to the configured knife.rb value if ssh_password_ng is false" do @knife.config[:ssh_password_ng] = false expect(@knife).not_to receive(:get_password) @knife.configure_password diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb index c7ca98d2dc..180d798d5b 100644 --- a/spec/unit/knife/ssl_check_spec.rb +++ b/spec/unit/knife/ssl_check_spec.rb @@ -67,10 +67,10 @@ describe Chef::Knife::SslCheck do it "prints an error and exits" do expect { ssl_check.run }.to raise_error(SystemExit) - expected_stdout=<<-E + expected_stdout = <<-E USAGE: knife ssl check [URL] (options) E - expected_stderr=<<-E + expected_stderr = <<-E ERROR: Given URI: `foo.test' is invalid E expect(stdout_io.string).to eq(expected_stdout) @@ -83,10 +83,10 @@ E it "prints an error and exits" do expect { ssl_check.run }.to raise_error(SystemExit) - expected_stdout=<<-E + expected_stdout = <<-E USAGE: knife ssl check [URL] (options) E - expected_stderr=<<-E + expected_stderr = <<-E ERROR: Given URI: `#{name_args[0]}' is invalid E expect(stdout_io.string).to eq(expected_stdout) diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb index 4f31285fca..8bb4810b88 100644 --- a/spec/unit/knife/ssl_fetch_spec.rb +++ b/spec/unit/knife/ssl_fetch_spec.rb @@ -68,10 +68,10 @@ describe Chef::Knife::SslFetch do it "prints an error and exits" do expect { ssl_fetch.run }.to raise_error(SystemExit) - expected_stdout=<<-E + expected_stdout = <<-E USAGE: knife ssl fetch [URL] (options) E - expected_stderr=<<-E + expected_stderr = <<-E ERROR: Given URI: `foo.test' is invalid E expect(stdout_io.string).to eq(expected_stdout) @@ -84,10 +84,10 @@ E it "prints an error and exits" do expect { ssl_fetch.run }.to raise_error(SystemExit) - expected_stdout=<<-E + expected_stdout = <<-E USAGE: knife ssl fetch [URL] (options) E - expected_stderr=<<-E + expected_stderr = <<-E ERROR: Given URI: `#{name_args[0]}' is invalid E expect(stdout_io.string).to eq(expected_stdout) diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb index 536a5c317a..473598fd85 100644 --- a/spec/unit/knife/status_spec.rb +++ b/spec/unit/knife/status_spec.rb @@ -34,10 +34,10 @@ describe Chef::Knife::Status do end describe "run" do - let(:opts) {{filter_result: + let(:opts) {{ 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"]}}} + ec2: ["ec2"], run_list: ["run_list"], platform: ["platform"], + platform_version: ["platform_version"], chef_environment: ["chef_environment"] } }} 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 7983df8b41..5ab77d2df6 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -47,12 +47,12 @@ describe Chef::Knife::UserCreate do it "displays the osc warning" do expect(knife.ui).to receive(:warn).with(knife.osc_11_warning) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "calls knife osc_user create" do expect(knife).to receive(:run_osc_11_user_create) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end end @@ -186,7 +186,7 @@ describe Chef::Knife::UserCreate do context "when a private_key is returned" do before do - allow(knife).to receive(:create_user_from_hash).and_return(Chef::UserV1.from_hash(knife.user.to_hash.merge({"private_key" => "some_private_key"}))) + allow(knife).to receive(:create_user_from_hash).and_return(Chef::UserV1.from_hash(knife.user.to_hash.merge({ "private_key" => "some_private_key" }))) end context "when --file is passed" do diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb index de37797d3c..0f71b39a41 100644 --- a/spec/unit/knife/user_delete_spec.rb +++ b/spec/unit/knife/user_delete_spec.rb @@ -41,12 +41,12 @@ describe Chef::Knife::UserDelete do it "displays the osc warning" do expect(knife.ui).to receive(:warn).with(knife.osc_11_warning) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "forwards the command to knife osc_user edit" do expect(knife).to receive(:run_osc_11_user_delete) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end end diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb index d7db1aac29..ec118ed181 100644 --- a/spec/unit/knife/user_edit_spec.rb +++ b/spec/unit/knife/user_edit_spec.rb @@ -36,17 +36,17 @@ describe Chef::Knife::UserEdit do context "when the username field is not supported by the server" do before do allow(knife).to receive(:run_osc_11_user_edit).and_raise(SystemExit) - allow(Chef::UserV1).to receive(:load).and_return({"username" => nil}) + allow(Chef::UserV1).to receive(:load).and_return({ "username" => nil }) end it "displays the osc warning" do expect(knife.ui).to receive(:warn).with(knife.osc_11_warning) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "forwards the command to knife osc_user edit" do expect(knife).to receive(:run_osc_11_user_edit) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end end diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb index cc85578bf6..d650ff9fb8 100644 --- a/spec/unit/knife/user_reregister_spec.rb +++ b/spec/unit/knife/user_reregister_spec.rb @@ -41,12 +41,12 @@ describe Chef::Knife::UserReregister do it "displays the osc warning" do expect(knife.ui).to receive(:warn).with(knife.osc_11_warning) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "forwards the command to knife osc_user edit" do expect(knife).to receive(:run_osc_11_user_reregister) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end end diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb index b82e3e2640..3a38161b34 100644 --- a/spec/unit/knife/user_show_spec.rb +++ b/spec/unit/knife/user_show_spec.rb @@ -41,12 +41,12 @@ describe Chef::Knife::UserShow do it "displays the osc warning" do expect(knife.ui).to receive(:warn).with(knife.osc_11_warning) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end it "forwards the command to knife osc_user edit" do expect(knife).to receive(:run_osc_11_user_show) - expect{ knife.run }.to raise_error(SystemExit) + expect { knife.run }.to raise_error(SystemExit) end end |