diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-10-26 11:51:28 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-10-26 11:51:28 -0700 |
commit | 8837ebfda2a4292976d44ec564f349f357349fc1 (patch) | |
tree | 765d2e98a4c0bead2030f411f07613207e5070b5 /spec | |
parent | 4d13c5acaa8596eab50b7d62252a6d94ab290d61 (diff) | |
download | chef-simplify_regex.tar.gz |
Simplify some regexes by removing redundant character classessimplify_regex
New RuboCop here. There's no need for character classes when all we have is a single character.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/resource/apt_package_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/configure_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/resource/breakpoint_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/shell_spec.rb | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb index 228882a2e7..6a1031feb8 100644 --- a/spec/functional/resource/apt_package_spec.rb +++ b/spec/functional/resource/apt_package_spec.rb @@ -326,7 +326,7 @@ describe Chef::Resource::AptPackage, metadata do pkg_check = shell_out!("dpkg -l chef-integration-test", returns: [0, 1]) if pkg_check.exitstatus == 0 - expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/) + expect(pkg_check.stdout).to match(/un\s+chef-integration-test/) end end @@ -359,7 +359,7 @@ describe Chef::Resource::AptPackage, metadata do it "upgrades the package for action :upgrade" do package_resource.run_action(:upgrade) dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0]) - expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/) + expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/) expect(package_resource).to be_updated_by_last_action end @@ -373,7 +373,7 @@ describe Chef::Resource::AptPackage, metadata do it "upgrades the package for action :install" do package_resource.run_action(:install) dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0]) - expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/) + expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/) expect(package_resource).to be_updated_by_last_action end end diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 6b41e54778..d642d003ae 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -157,9 +157,9 @@ describe Chef::Knife::Configure do expect(::File).to receive(:open).with("/home/you/.chef/credentials", "w").and_yield config_file @knife.config[:repository] = "/home/you/chef-repo" @knife.run - expect(config_file.string).to match(/^client_name[\s]+=[\s]+'#{Etc.getlogin}'$/) - expect(config_file.string).to match(%r{^client_key[\s]+=[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$}) - expect(config_file.string).to match(/^chef_server_url\s+=[\s]+'#{default_server_url}'$/) + expect(config_file.string).to match(/^client_name\s+=\s+'#{Etc.getlogin}'$/) + expect(config_file.string).to match(%r{^client_ky[\s=[\s+'/home/you/.chef/#{Etc.getlogin}.pem'$}) + expect(config_file.string).to match(/^chef_server_url\s+=\s+'#{default_server_url}'$/) end it "creates a new client when given the --initial option" do diff --git a/spec/unit/resource/breakpoint_spec.rb b/spec/unit/resource/breakpoint_spec.rb index 0804c27cab..4b1aed6f8e 100644 --- a/spec/unit/resource/breakpoint_spec.rb +++ b/spec/unit/resource/breakpoint_spec.rb @@ -58,7 +58,7 @@ describe Chef::Resource::Breakpoint do it "names itself after the line number of the file where it's created" do resource = Chef::Resource::Breakpoint.new - expect(resource.name).to match(/breakpoint_spec\.rb\:[\d]{2}\:in \`new\'$/) + expect(resource.name).to match(/breakpoint_spec\.rb\:\d{2}\:in \`new\'$/) end end diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb index 18b622698e..9c1a0c8e3d 100644 --- a/spec/unit/shell_spec.rb +++ b/spec/unit/shell_spec.rb @@ -150,8 +150,8 @@ describe Shell do end it "creates a help banner with the command descriptions" do - expect(@chef_object.help_banner).to match(/^\|\ Command[\s]+\|\ Description[\s]*$/) - expect(@chef_object.help_banner).to match(/^\|\ rspec_method[\s]+\|\ rspecin\'[\s]*$/) + expect(@chef_object.help_banner).to match(/^\|\ Command\s+\|\ Description\s*$/) + expect(@chef_object.help_banner).to match(/^\|\ rspec_method\s+\|\ rspecin\'\s*$/) end end |