diff options
author | Tim Smith <tsmith@chef.io> | 2019-10-27 21:38:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-27 21:38:16 -0700 |
commit | 456b3f70db1bc20a9adecfbc950a79583d400794 (patch) | |
tree | c3d2714324c23948d05b85c993d761ba01a540e4 /spec | |
parent | 83acd8b256645efc86d87b4dee41c0ee192946d3 (diff) | |
parent | a0bc42e094593da343e6471cd1ba744560fdb5c8 (diff) | |
download | chef-456b3f70db1bc20a9adecfbc950a79583d400794.tar.gz |
Merge pull request #9028 from MsysTechnologiesllc/VSingh/fix-knife-ssh-name-args
Fix Exception: NoMethodError: undefined method join for nil:NilClass
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/ssh_spec.rb | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 9cefcba84f..ea957ee5f9 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -360,29 +360,39 @@ describe Chef::Knife::Ssh do end describe "#run" do - before do - @query = Chef::Search::Query.new - expect(@query).to receive(:search).and_yield(@node_foo) - allow(Chef::Search::Query).to receive(:new).and_return(@query) - allow(@knife).to receive(:ssh_command).and_return(exit_code) - @knife.name_args = ["*:*", "false"] + + it "should print usage and exit when a SEARCH QUERY is not provided" do + @knife.name_args = [] + expect(@knife).to receive(:show_usage) + expect(@knife.ui).to receive(:fatal).with(/You must specify the SEARCH QUERY./) + expect { @knife.run }.to raise_error(SystemExit) end - context "with an error" do - let(:exit_code) { 1 } + context "exit" do + before do + @query = Chef::Search::Query.new + expect(@query).to receive(:search).and_yield(@node_foo) + allow(Chef::Search::Query).to receive(:new).and_return(@query) + allow(@knife).to receive(:ssh_command).and_return(exit_code) + @knife.name_args = ["*:*", "false"] + end + + context "with an error" do + let(:exit_code) { 1 } - it "should exit with a non-zero exit code" do - expect(@knife).to receive(:exit).with(exit_code) - @knife.run + it "should exit with a non-zero exit code" do + expect(@knife).to receive(:exit).with(exit_code) + @knife.run + end end - end - context "with no error" do - let(:exit_code) { 0 } + context "with no error" do + let(:exit_code) { 0 } - it "should not exit" do - expect(@knife).not_to receive(:exit) - @knife.run + it "should not exit" do + expect(@knife).not_to receive(:exit) + @knife.run + end end end end |