diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-21 21:21:10 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-21 21:21:10 -0800 |
commit | 1002fd4449e7d8e95aa09586d31220d6897d7a2c (patch) | |
tree | 4da5f6c58417e70e08438290555d71298d2e3b8b /spec/unit/knife | |
parent | 2478b8252d3c701da2e0fd4835028da53c59c498 (diff) | |
download | chef-1002fd4449e7d8e95aa09586d31220d6897d7a2c.tar.gz |
Avoid ambiguous regexesambiguous_regex
Just makes it a bit easier to read.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit/knife')
-rw-r--r-- | spec/unit/knife/client_create_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/knife/configure_client_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_delete_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_download_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_list_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_metadata_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/environment_compare_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/supermarket_download_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/knife/supermarket_list_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/supermarket_search_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/tag_create_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/tag_delete_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/user_create_spec.rb | 2 |
13 files changed, 34 insertions, 34 deletions
diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb index de0888f375..d8b67de101 100644 --- a/spec/unit/knife/client_create_spec.rb +++ b/spec/unit/knife/client_create_spec.rb @@ -81,7 +81,7 @@ describe Chef::Knife::ClientCreate do it "prints a relevant error message" do expect { knife.run }.to raise_error(SystemExit) - expect(stderr.string).to match /You cannot pass --public-key and --prevent-keygen/ + expect(stderr.string).to match(/You cannot pass --public-key and --prevent-keygen/) end end @@ -93,7 +93,7 @@ describe Chef::Knife::ClientCreate do it "should print a message upon creation" do expect(knife).to receive(:create_client) knife.run - expect(stderr.string).to match /Created client.*adam/i + expect(stderr.string).to match(/Created client.*adam/i) end it "should set the Client name" do diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb index be76250e7c..b104718c89 100644 --- a/spec/unit/knife/configure_client_spec.rb +++ b/spec/unit/knife/configure_client_spec.rb @@ -59,21 +59,21 @@ describe Chef::Knife::ConfigureClient do allow(FileUtils).to receive(:mkdir_p) @knife.run expect(@client_file.string).to match %r{chef_server_url\s+'https\://chef\.example\.com'} - expect(@client_file.string).to match /validation_client_name\s+'chef-validator'/ + expect(@client_file.string).to match(/validation_client_name\s+'chef-validator'/) end it "should write out the validation.pem file" do allow(FileUtils).to receive(:mkdir_p) @knife.run - expect(@validation_file.string).to match /foo_bar_baz/ + expect(@validation_file.string).to match(/foo_bar_baz/) end it "should print information on what is being configured" do allow(FileUtils).to receive(:mkdir_p) @knife.run - expect(@stderr.string).to match /creating client configuration/i - expect(@stderr.string).to match /writing client\.rb/i - expect(@stderr.string).to match /writing validation\.pem/i + expect(@stderr.string).to match(/creating client configuration/i) + expect(@stderr.string).to match(/writing client\.rb/i) + expect(@stderr.string).to match(/writing validation\.pem/i) end end end diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb index 4de907e94d..f2aa7e1be0 100644 --- a/spec/unit/knife/cookbook_delete_spec.rb +++ b/spec/unit/knife/cookbook_delete_spec.rb @@ -152,7 +152,7 @@ describe Chef::Knife::CookbookDelete do it "should print an error" do @knife.available_versions - expect(@stderr.string).to match /error.+cannot find a cookbook named foobar/i + expect(@stderr.string).to match(/error.+cannot find a cookbook named foobar/i) end it "should return nil" do @@ -204,7 +204,7 @@ describe Chef::Knife::CookbookDelete do it "should output that the cookbook was deleted" do allow(@knife).to receive(:delete_request) @knife.delete_version_without_confirmation("1.0.0") - expect(@stderr.string).to match /deleted cookbook\[foobar\]\[1.0.0\]/im + expect(@stderr.string).to match(/deleted cookbook\[foobar\]\[1.0.0\]/im) end describe "with --print-after" do diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index 62b6e58c75..c8903dea5b 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -138,9 +138,9 @@ describe Chef::Knife::CookbookDownload do expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false) @knife.run %w{attributes recipes templates}.each do |segment| - expect(@stderr.string).to match /downloading #{segment}/im + expect(@stderr.string).to match(/downloading #{segment}/im) end - expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im + expect(@stderr.string).to match(/downloading foobar cookbook version 1\.0\.0/im) expect(@stderr.string).to match %r{cookbook downloaded to /var/tmp/chef/foobar-1\.0\.0}im end diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb index e34b58b672..4cf806c6f0 100644 --- a/spec/unit/knife/cookbook_list_spec.rb +++ b/spec/unit/knife/cookbook_list_spec.rb @@ -41,7 +41,7 @@ describe Chef::Knife::CookbookList do .and_return(@cookbook_data) @knife.run @cookbook_names.each do |item| - expect(@stdout.string).to match /#{item}\s+1\.0\.1/ + expect(@stdout.string).to match(/#{item}\s+1\.0\.1/) end end @@ -79,7 +79,7 @@ describe Chef::Knife::CookbookList do .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/ + expect(@stdout.string).to match(/#{item}\s+1\.0\.1\s+1\.0\.0/) end end end diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb index 04d851be6a..732cf78421 100644 --- a/spec/unit/knife/cookbook_metadata_spec.rb +++ b/spec/unit/knife/cookbook_metadata_spec.rb @@ -145,20 +145,20 @@ describe Chef::Knife::CookbookMetadata do create_metadata_rb(name: "foobar", version: "1.0.0", depends: [ "foo:bar", ">> 0.2" ]) expect(Chef::Cookbook::Metadata).not_to receive(:validate_json) expect { knife.run }.to raise_error(SystemExit) - expect(stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im + expect(stderr.string).to match(/error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im) end it "should fail for obsolete format in metadata.rb (sadly)" do create_metadata_rb(name: "foobar", version: "1.0.0", depends: [ "foo:bar", "> 0.2", "< 1.0" ]) expect(Chef::Cookbook::Metadata).not_to receive(:validate_json) expect { knife.run }.to raise_error(SystemExit) - expect(stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im + expect(stderr.string).to match(/error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im) end it "should fail for obsolete operators in metadata.json" do create_metadata_json(name: "foobar", version: "1.0.0", dependencies: { "foo:bar" => ">> 0.2" }) expect { knife.run }.to raise_error(SystemExit) - expect(stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im + expect(stderr.string).to match(/error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im) end it "should not fail for unknown field in metadata.rb" do diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb index 82960f3db3..bfaeed0c82 100644 --- a/spec/unit/knife/environment_compare_spec.rb +++ b/spec/unit/knife/environment_compare_spec.rb @@ -62,7 +62,7 @@ describe Chef::Knife::EnvironmentCompare do @knife.config[:format] = "summary" @knife.run @environments.each_key do |item| - expect(@stdout.string).to(match /#{item}/) && expect(@stdout.string.lines.count).to(be 4) + expect(@stdout.string).to(match(/#{item}/)) && expect(@stdout.string.lines.count).to(be 4) end end @@ -79,7 +79,7 @@ describe Chef::Knife::EnvironmentCompare do @knife.config[:mismatch] = true @knife.run @constraints.each_value do |ver| - expect(@stdout.string).to match /#{ver[1]}/ + expect(@stdout.string).to match(/#{ver[1]}/) end end @@ -97,7 +97,7 @@ describe Chef::Knife::EnvironmentCompare do @knife.config[:all] = true @knife.run @constraints.each_value do |ver| - expect(@stdout.string).to match /#{ver[1]}/ + expect(@stdout.string).to match(/#{ver[1]}/) end end diff --git a/spec/unit/knife/supermarket_download_spec.rb b/spec/unit/knife/supermarket_download_spec.rb index e7058c24e9..5d15e74966 100644 --- a/spec/unit/knife/supermarket_download_spec.rb +++ b/spec/unit/knife/supermarket_download_spec.rb @@ -86,8 +86,8 @@ describe Chef::Knife::SupermarketDownload do .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 - expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i + expect(@stderr.string).to match(/downloading apache2.+version.+#{Regexp.escape(@version)}/i) + expect(@stderr.string).to match(/cookbook save.+#{Regexp.escape(@file)}/i) end end @@ -95,8 +95,8 @@ describe Chef::Knife::SupermarketDownload do it "should download the latest version" do expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @knife.run - expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i - expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i + expect(@stderr.string).to match(/downloading apache2.+version.+#{Regexp.escape(@version)}/i) + expect(@stderr.string).to match(/cookbook save.+#{Regexp.escape(@file)}/i) end context "with -f or --file" do @@ -108,8 +108,8 @@ describe Chef::Knife::SupermarketDownload do it "should download the cookbook to the desired file" do @knife.run - expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i - expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i + expect(@stderr.string).to match(/downloading apache2.+version.+#{Regexp.escape(@version)}/i) + expect(@stderr.string).to match(/cookbook save.+#{Regexp.escape(@file)}/i) end end @@ -140,8 +140,8 @@ describe Chef::Knife::SupermarketDownload do .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 - expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i + expect(@stderr.string).to match(/downloading apache2.+version.+#{Regexp.escape(@version)}/i) + expect(@stderr.string).to match(/cookbook save.+#{Regexp.escape(@file)}/i) end end diff --git a/spec/unit/knife/supermarket_list_spec.rb b/spec/unit/knife/supermarket_list_spec.rb index db96ff5d3c..a1acccaaaa 100644 --- a/spec/unit/knife/supermarket_list_spec.rb +++ b/spec/unit/knife/supermarket_list_spec.rb @@ -52,7 +52,7 @@ describe Chef::Knife::SupermarketList do it "should display all supermarket cookbooks" do knife.run cookbooks_data.each do |item| - expect(stdout.string).to match /#{item["cookbook_name"]}\s/ + expect(stdout.string).to match(/#{item["cookbook_name"]}\s/) end end @@ -61,8 +61,8 @@ describe Chef::Knife::SupermarketList do knife.config[:with_uri] = true knife.run cookbooks_data.each do |item| - expect(stdout.string).to match /#{item["cookbook_name"]}\s/ - expect(stdout.string).to match /#{item["cookbook"]}\s/ + expect(stdout.string).to match(/#{item["cookbook_name"]}\s/) + expect(stdout.string).to match(/#{item["cookbook"]}\s/) end end end diff --git a/spec/unit/knife/supermarket_search_spec.rb b/spec/unit/knife/supermarket_search_spec.rb index 5d3c0accf0..cba2f615aa 100644 --- a/spec/unit/knife/supermarket_search_spec.rb +++ b/spec/unit/knife/supermarket_search_spec.rb @@ -65,7 +65,7 @@ describe Chef::Knife::SupermarketSearch do knife.name_args = ["mysql"] knife.run cookbooks_data.each do |item| - expect(stdout.string).to match /#{item["cookbook_name"]}\s/ + expect(stdout.string).to match(/#{item["cookbook_name"]}\s/) end end end diff --git a/spec/unit/knife/tag_create_spec.rb b/spec/unit/knife/tag_create_spec.rb index 6a3ced3f5b..a1a4923871 100644 --- a/spec/unit/knife/tag_create_spec.rb +++ b/spec/unit/knife/tag_create_spec.rb @@ -17,7 +17,7 @@ describe Chef::Knife::TagCreate do it "can create tags on a node" do @knife.run expect(@node.tags).to eq(["happytag"]) - expect(@stderr.string).to match /created tags happytag.+node webmonkey.example.com/i + expect(@stderr.string).to match(/created tags happytag.+node webmonkey.example.com/i) end end end diff --git a/spec/unit/knife/tag_delete_spec.rb b/spec/unit/knife/tag_delete_spec.rb index 5c932706af..4201196de0 100644 --- a/spec/unit/knife/tag_delete_spec.rb +++ b/spec/unit/knife/tag_delete_spec.rb @@ -19,7 +19,7 @@ describe Chef::Knife::TagDelete do expect(@node.tags).to eq(%w{sadtag happytag}) @knife.run expect(@node.tags).to eq(["happytag"]) - expect(@stderr.string).to match /deleted.+sadtag/i + expect(@stderr.string).to match(/deleted.+sadtag/i) end end end diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb index 3c9a9d3a78..be3d2fd99c 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -112,7 +112,7 @@ describe Chef::Knife::UserCreate do it "prints a relevant error message" do expect { knife.run }.to raise_error(SystemExit) - expect(stderr.string).to match /You cannot pass --user-key and --prevent-keygen/ + expect(stderr.string).to match(/You cannot pass --user-key and --prevent-keygen/) end end |