From d2567df602b65102b908a918b5200898b137a614 Mon Sep 17 00:00:00 2001 From: Marc Chamberland Date: Sat, 6 Apr 2019 23:16:54 -0400 Subject: addressing comments by coderanger Signed-off-by: Marc Chamberland --- spec/functional/version_spec.rb | 2 +- spec/integration/solo/solo_spec.rb | 6 +++--- spec/unit/application/client_spec.rb | 6 +++--- spec/unit/application/solo_spec.rb | 4 ++-- spec/unit/knife_spec.rb | 22 +++++++++++----------- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'spec') diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb index 90a0aa19f6..d968c36e8c 100644 --- a/spec/functional/version_spec.rb +++ b/spec/functional/version_spec.rb @@ -28,7 +28,7 @@ describe "Chef Versions" do binaries.each do |binary| it "#{binary} version should be sane" do - expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to include("#{Chef::Dist::PRODUCT}: #{Chef::VERSION}") + expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to match(/.*: #{Chef::VERSION}/) end end diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index 76304cc334..efd889c5d0 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -163,7 +163,7 @@ describe "chef-solo" do ruby_block "sleeping" do block do retries = 200 - while IO.read(Chef::Config[:log_location]) !~ /#{Chef::Dist::PRODUCT} client .* is running, will wait for it to finish and then run./ + while IO.read(Chef::Config[:log_location]) !~ /.* client .* is running, will wait for it to finish and then run./ sleep 0.1 raise "we ran out of retries" if ( retries -= 1 ) <= 0 end @@ -207,10 +207,10 @@ describe "chef-solo" do run_log = File.read(path_to("logs/runs.log")) # second run should have a message which indicates it's waiting for the first run - expect(run_log).to match(/#{Chef::Dist::PRODUCT} client .* is running, will wait for it to finish and then run./) + expect(run_log).to match(/.* client .* is running, will wait for it to finish and then run./) # both of the runs should succeed - expect(run_log.lines.reject { |l| !l.include? "INFO: #{Chef::Dist::PRODUCT} Run complete in" }.length).to eq(2) + expect(run_log.lines.reject { |l| !l.include? "Run complete in" }.length).to eq(2) end end diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index a24f74b4a0..8daba1d660 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -1,4 +1,4 @@ -# + # Author:: AJ Christensen () # Copyright:: Copyright 2008-2018, Chef Software Inc. # License:: Apache License, Version 2.0 @@ -326,10 +326,10 @@ describe Chef::Application::Client, "reconfigure" do Chef::Config[:interval] = 600 allow(ChefConfig).to receive(:windows?).and_return(false) expect(Chef::Application).to receive(:fatal!).with( - "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in #{Chef::Dist::PRODUCT} 12. + /Unforked .* interval runs are disabled in .* 12\. Configuration settings: interval = 600 seconds -Enable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options." +Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./ ) app.reconfigure end diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index 4d9d1371f7..1a4961f025 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -64,10 +64,10 @@ describe Chef::Application::Solo do it "should terminate with message" do expect(Chef::Application).to receive(:fatal!).with( - "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in #{Chef::Dist::PRODUCT} 12. + /Unforked .* interval runs are disabled in .* 12\. Configuration settings: interval = 600 seconds -Enable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options." +Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./ ) app.reconfigure end diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index d6d1e7758c..ff89bc6f30 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -458,7 +458,7 @@ describe Chef::Knife do allow(knife).to receive(:username).and_return("sadpanda") knife.run_with_pretty_exceptions expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action}) - expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your #{Chef::Dist::PRODUCT} server may need to be added to NO_PROXY.}) + expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your .* server may need to be added to NO_PROXY.}) expect(stderr.string).to match(%r{Response: y u no administrator}) end end @@ -494,9 +494,9 @@ describe Chef::Knife do allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("406 Not Acceptable", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to include("The request that #{Chef::Dist::KNIFE} sent was using API version 10000000") - expect(stderr.string).to include("The #{Chef::Dist::PRODUCT} server you sent the request to supports a min API verson of 0 and a max API version of 1") - expect(stderr.string).to include("Please either update your #{Chef::Dist::PRODUCT} client or server to be a compatible set") + expect(stderr.string).to match(/The request that .* sent was using API version 10000000/) + expect(stderr.string).to match(/The .* server you sent the request to supports a min API verson of 0 and a max API version of 1/) + expect(stderr.string).to match(/Please either update your .* client or server to be a compatible set/) end it "formats 500s nicely" do @@ -542,8 +542,8 @@ describe Chef::Knife do it "formats NameError and NoMethodError nicely" do allow(knife).to receive(:run).and_raise(NameError.new("Undefined constant FUUU")) knife.run_with_pretty_exceptions - expect(stderr.string).to match(%r{ERROR: #{Chef::Dist::KNIFE} encountered an unexpected error}) - expect(stderr.string).to match(%r{This may be a bug in the 'knife' #{Chef::Dist::KNIFE} command or plugin}) + expect(stderr.string).to match(%r{ERROR: .* encountered an unexpected error}) + expect(stderr.string).to match(%r{This may be a bug in the 'knife' .* command or plugin}) expect(stderr.string).to match(%r{Exception: NameError: Undefined constant FUUU}) end @@ -562,7 +562,7 @@ describe Chef::Knife do # *nix = Errno::ECONNREFUSED: Connection refused # win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. expect(stderr.string).to match(%r{ERROR: Network Error: .* - y u no shut up}) - expect(stderr.string).to match(%r{Check your #{Chef::Dist::KNIFE} configuration and network settings}) + expect(stderr.string).to match(%r{Check your .* configuration and network settings}) end it "formats SSL errors nicely and suggests to use `knife ssl check` and `knife ssl fetch`" do @@ -573,11 +573,11 @@ describe Chef::Knife do expected_message = <<~MSG ERROR: Could not establish a secure connection to the server. - Use `#{Chef::Dist::KNIFE} ssl check` to troubleshoot your SSL configuration. - If your #{Chef::Dist::PRODUCT} Server uses a self-signed certificate, you can use - `#{Chef::Dist::KNIFE} ssl fetch` to make #{Chef::Dist::KNIFE} trust the server's certificates. + Use `.* ssl check` to troubleshoot your SSL configuration. + If your .* Server uses a self-signed certificate, you can use + `.* ssl fetch` to make .* trust the server's certificates. MSG - expect(stderr.string).to include(expected_message) + expect(stderr.string).to match(expected_message) end end -- cgit v1.2.1