summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-11-21 21:21:10 -0800
committerTim Smith <tsmith84@gmail.com>2020-11-21 21:21:10 -0800
commit1002fd4449e7d8e95aa09586d31220d6897d7a2c (patch)
tree4da5f6c58417e70e08438290555d71298d2e3b8b
parent2478b8252d3c701da2e0fd4835028da53c59c498 (diff)
downloadchef-1002fd4449e7d8e95aa09586d31220d6897d7a2c.tar.gz
Avoid ambiguous regexesambiguous_regex
Just makes it a bit easier to read. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/route.rb4
-rw-r--r--spec/functional/mixin/powershell_out_spec.rb8
-rw-r--r--spec/integration/knife/client_key_create_spec.rb2
-rw-r--r--spec/integration/knife/node_create_spec.rb2
-rw-r--r--spec/integration/knife/node_environment_set_spec.rb2
-rw-r--r--spec/integration/knife/node_run_list_add_spec.rb8
-rw-r--r--spec/integration/knife/node_run_list_remove_spec.rb2
-rw-r--r--spec/integration/knife/node_run_list_set_spec.rb2
-rw-r--r--spec/integration/knife/node_show_spec.rb2
-rw-r--r--spec/integration/recipes/notifies_spec.rb2
-rw-r--r--spec/integration/recipes/provider_choice.rb4
-rw-r--r--spec/support/shared/unit/knife_shared.rb2
-rw-r--r--spec/unit/knife/client_create_spec.rb4
-rw-r--r--spec/unit/knife/configure_client_spec.rb10
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb6
-rw-r--r--spec/unit/knife/environment_compare_spec.rb6
-rw-r--r--spec/unit/knife/supermarket_download_spec.rb16
-rw-r--r--spec/unit/knife/supermarket_list_spec.rb6
-rw-r--r--spec/unit/knife/supermarket_search_spec.rb2
-rw-r--r--spec/unit/knife/tag_create_spec.rb2
-rw-r--r--spec/unit/knife/tag_delete_spec.rb2
-rw-r--r--spec/unit/knife/user_create_spec.rb2
-rw-r--r--spec/unit/resource/service_spec.rb4
26 files changed, 56 insertions, 56 deletions
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index 8a304a7e45..614d56aa22 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -188,8 +188,8 @@ class Chef
logger.trace("#{new_resource} writing default route #{new_resource.gateway} to #{network_file_name}")
if ::File.exist?(network_file_name)
network_file = ::Chef::Util::FileEdit.new(network_file_name)
- network_file.search_file_replace_line /^GATEWAY=/, "GATEWAY=#{new_resource.gateway}"
- network_file.insert_line_if_no_match /^GATEWAY=/, "GATEWAY=#{new_resource.gateway}"
+ network_file.search_file_replace_line(/^GATEWAY=/, "GATEWAY=#{new_resource.gateway}")
+ network_file.insert_line_if_no_match(/^GATEWAY=/, "GATEWAY=#{new_resource.gateway}")
network_file.write_file
else
network_file = ::File.new(network_file_name, "w")
diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb
index 22df0f92c9..801910cd87 100644
--- a/spec/functional/mixin/powershell_out_spec.rb
+++ b/spec/functional/mixin/powershell_out_spec.rb
@@ -23,15 +23,15 @@ describe Chef::Mixin::PowershellOut, :windows_only do
describe "#powershell_out" do
it "runs a powershell command and collects stdout" do
- expect(powershell_out("get-process").run_command.stdout).to match /Handles/
+ expect(powershell_out("get-process").run_command.stdout).to match(/Handles/)
end
it "uses :powershell by default" do
- expect(powershell_out("$PSVersionTable").run_command.stdout).to match /CLRVersion/
+ expect(powershell_out("$PSVersionTable").run_command.stdout).to match(/CLRVersion/)
end
it ":pwsh interpreter uses core edition", :pwsh_installed do
- expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match /Core/
+ expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match(/Core/)
end
it "does not raise exceptions when the command is invalid" do
@@ -41,7 +41,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
describe "#powershell_out!" do
it "runs a powershell command and collects stdout" do
- expect(powershell_out!("get-process").run_command.stdout).to match /Handles/
+ expect(powershell_out!("get-process").run_command.stdout).to match(/Handles/)
end
it "raises exceptions when the command is invalid" do
diff --git a/spec/integration/knife/client_key_create_spec.rb b/spec/integration/knife/client_key_create_spec.rb
index 179b0f5911..b9838d6718 100644
--- a/spec/integration/knife/client_key_create_spec.rb
+++ b/spec/integration/knife/client_key_create_spec.rb
@@ -39,7 +39,7 @@ describe "knife client key create", :workstation do
it "creates a new client key with an expiration date" do
date = "2017-12-31T23:59:59Z"
knife("client key create -k new -e #{date} bah").should_succeed stderr: /^#{out}/, stdout: /.*BEGIN RSA PRIVATE KEY/
- knife("client key show bah new").should_succeed /expiration_date:.*#{date}/
+ knife("client key show bah new").should_succeed(/expiration_date:.*#{date}/)
end
it "refuses to add an already existing key" do
diff --git a/spec/integration/knife/node_create_spec.rb b/spec/integration/knife/node_create_spec.rb
index 76aa8bbfae..e8f6d71694 100644
--- a/spec/integration/knife/node_create_spec.rb
+++ b/spec/integration/knife/node_create_spec.rb
@@ -34,7 +34,7 @@ describe "knife node create", :workstation do
it "creates a new validator node" do
knife("node create bah").should_succeed out
- knife("node show bah").should_succeed /Node Name: bah/
+ knife("node show bah").should_succeed(/Node Name: bah/)
end
it "refuses to add an existing node" do
diff --git a/spec/integration/knife/node_environment_set_spec.rb b/spec/integration/knife/node_environment_set_spec.rb
index 3a407d1b20..16a86dbc30 100644
--- a/spec/integration/knife/node_environment_set_spec.rb
+++ b/spec/integration/knife/node_environment_set_spec.rb
@@ -31,7 +31,7 @@ describe "knife node environment set", :workstation do
end
it "sets an environment on a node" do
- knife("node environment set cons lisp").should_succeed /chef_environment:.*lisp/
+ knife("node environment set cons lisp").should_succeed(/chef_environment:.*lisp/)
knife("node show cons -a chef_environment").should_succeed <<~EOM
cons:
chef_environment: lisp
diff --git a/spec/integration/knife/node_run_list_add_spec.rb b/spec/integration/knife/node_run_list_add_spec.rb
index 8b17b36a67..f13e584526 100644
--- a/spec/integration/knife/node_run_list_add_spec.rb
+++ b/spec/integration/knife/node_run_list_add_spec.rb
@@ -30,7 +30,7 @@ describe "knife node run list add", :workstation do
end
it "sets the run list" do
- knife("node run list add cons recipe[foo]").should_succeed /run_list:\s*recipe\[foo\]\n/
+ knife("node run list add cons recipe[foo]").should_succeed(/run_list:\s*recipe\[foo\]\n/)
end
end
@@ -40,15 +40,15 @@ describe "knife node run list add", :workstation do
end
it "appends to the run list" do
- knife("node run list add cons recipe[foo]").should_succeed /run_list:\n\s*recipe\[bar\]\n\s*recipe\[foo\]\n/m
+ knife("node run list add cons recipe[foo]").should_succeed(/run_list:\n\s*recipe\[bar\]\n\s*recipe\[foo\]\n/m)
end
it "adds to the run list before the specified item" do
- knife("node run list add cons -b recipe[bar] recipe[foo]").should_succeed /run_list:\n\s*recipe\[foo\]\n\s*recipe\[bar\]\n/m
+ knife("node run list add cons -b recipe[bar] recipe[foo]").should_succeed(/run_list:\n\s*recipe\[foo\]\n\s*recipe\[bar\]\n/m)
end
it "adds to the run list after the specified item" do
- knife("node run list add cons -a recipe[bar] recipe[foo]").should_succeed /run_list:\n\s*recipe\[bar\]\n\s*recipe\[foo\]\n/m
+ knife("node run list add cons -a recipe[bar] recipe[foo]").should_succeed(/run_list:\n\s*recipe\[bar\]\n\s*recipe\[foo\]\n/m)
end
end
end
diff --git a/spec/integration/knife/node_run_list_remove_spec.rb b/spec/integration/knife/node_run_list_remove_spec.rb
index 96bc3650ea..55f224b5ac 100644
--- a/spec/integration/knife/node_run_list_remove_spec.rb
+++ b/spec/integration/knife/node_run_list_remove_spec.rb
@@ -30,7 +30,7 @@ describe "knife node run list remove", :workstation do
end
it "removes the item from the run list" do
- knife("node run list remove cons recipe[bar]").should_succeed /run_list:\s*recipe\[foo\]\n/m
+ knife("node run list remove cons recipe[bar]").should_succeed(/run_list:\s*recipe\[foo\]\n/m)
end
end
end
diff --git a/spec/integration/knife/node_run_list_set_spec.rb b/spec/integration/knife/node_run_list_set_spec.rb
index a63145f3b8..e642afc1ce 100644
--- a/spec/integration/knife/node_run_list_set_spec.rb
+++ b/spec/integration/knife/node_run_list_set_spec.rb
@@ -30,7 +30,7 @@ describe "knife node run list set", :workstation do
end
it "sets the run list" do
- knife("node run list set cons recipe[bar]").should_succeed /run_list:\s*recipe\[bar\]\n/m
+ knife("node run list set cons recipe[bar]").should_succeed(/run_list:\s*recipe\[bar\]\n/m)
end
it "with no role or recipe" do
diff --git a/spec/integration/knife/node_show_spec.rb b/spec/integration/knife/node_show_spec.rb
index 300c0b8540..cf3f166699 100644
--- a/spec/integration/knife/node_show_spec.rb
+++ b/spec/integration/knife/node_show_spec.rb
@@ -30,7 +30,7 @@ describe "knife node show", :workstation do
end
it "shows the node" do
- knife("node show cons").should_succeed /Run List:\s*recipe\[bar\], recipe\[foo\]\n/m
+ knife("node show cons").should_succeed(/Run List:\s*recipe\[bar\], recipe\[foo\]\n/m)
end
end
end
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index a31ba6370b..7dfa70dfe5 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -416,7 +416,7 @@ describe "notifications" do
EOM
result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
- expect(result.stdout).to match /\* log\[a, b\] action write/
+ expect(result.stdout).to match(/\* log\[a, b\] action write/)
result.error!
end
diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb
index 66aa58a432..f1d57260b6 100644
--- a/spec/integration/recipes/provider_choice.rb
+++ b/spec/integration/recipes/provider_choice.rb
@@ -30,8 +30,8 @@ describe "Recipe DSL methods" do
recipe = converge do
provider_thingy("blah") {}
end
- expect(recipe.logged_warnings).to match /hello from Chef::Provider::ProviderThingy/
- expect(recipe.logged_warnings).to match /you must use 'provides' to provide DSL/i
+ expect(recipe.logged_warnings).to match(/hello from Chef::Provider::ProviderThingy/)
+ expect(recipe.logged_warnings).to match(/you must use 'provides' to provide DSL/i)
end
end
end
diff --git a/spec/support/shared/unit/knife_shared.rb b/spec/support/shared/unit/knife_shared.rb
index ebdf7bddc7..3c7459cfcc 100644
--- a/spec/support/shared/unit/knife_shared.rb
+++ b/spec/support/shared/unit/knife_shared.rb
@@ -33,7 +33,7 @@ shared_examples_for "mandatory field missing" do
it "prints a relevant error message" do
expect { knife.run }.to raise_error(SystemExit)
- expect(stderr.string).to match /You must specify a #{fieldname}/
+ expect(stderr.string).to match(/You must specify a #{fieldname}/)
end
end
end
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
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index a94beece6b..24155e3b8f 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -62,7 +62,7 @@ describe Chef::Resource::Service do
it "does not accept a regexp for the service pattern" do
expect do
- resource.pattern /.*/
+ resource.pattern(/.*/)
end.to raise_error(ArgumentError)
end
@@ -89,7 +89,7 @@ describe Chef::Resource::Service do
it "does not accept a regexp for the init_command property" do
expect do
- resource.init_command /.*/
+ resource.init_command(/.*/)
end.to raise_error(ArgumentError)
end