diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-17 12:15:26 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-17 13:25:02 -0700 |
commit | a0c32511bc6634538374ca4b433032b8acd05f96 (patch) | |
tree | 15c7cfbd0d773488ab814e7c24f0c58505c9134b /spec/unit/mixin | |
parent | 3d0379a2ad531a0b3db5ed2827bf30ef07b26100 (diff) | |
download | chef-a0c32511bc6634538374ca4b433032b8acd05f96.tar.gz |
fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgrade
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/mixin')
-rw-r--r-- | spec/unit/mixin/api_version_request_handling_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/command_spec.rb | 31 | ||||
-rw-r--r-- | spec/unit/mixin/homebrew_user_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/params_validate_spec.rb | 105 | ||||
-rw-r--r-- | spec/unit/mixin/powershell_out_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/powershell_type_coercions_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/shell_out_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/xml_escape_spec.rb | 6 |
8 files changed, 82 insertions, 78 deletions
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb index 13b729538c..191dee643b 100644 --- a/spec/unit/mixin/api_version_request_handling_spec.rb +++ b/spec/unit/mixin/api_version_request_handling_spec.rb @@ -50,12 +50,12 @@ describe Chef::Mixin::ApiVersionRequestHandling do context "when x-ops-server-api-version header exists" do let(:min_server_version) { 2 } let(:max_server_version) { 4 } - let(:return_hash) { + let(:return_hash) do { "min_version" => min_server_version, "max_version" => max_server_version, } - } + end before(:each) do allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash)) diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index 0c2f6da188..e9f0dacad6 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -49,22 +49,24 @@ describe Chef::Mixin::Command, :volatile do end it "should end when the child process reads from STDIN and a block is given" do - expect {Timeout.timeout(10) do - popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr| - (1..5).each { |i| stdin.puts "#{i}" } + expect do + Timeout.timeout(10) do + popen4("ruby -e 'while gets; end'", :waitlast => true) do |pid, stdin, stdout, stderr| + (1..5).each { |i| stdin.puts "#{i}" } + end end - end - }.not_to raise_error + end.not_to raise_error end describe "when a process detaches but doesn't close STDOUT and STDERR [CHEF-584]" do it "returns immediately after the first child process exits" do - expect {Timeout.timeout(10) do - evil_forker = "exit if fork; 10.times { sleep 1}" - popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr| - end - end}.not_to raise_error + expect do + Timeout.timeout(10) do + evil_forker = "exit if fork; 10.times { sleep 1}" + popen4("ruby -e '#{evil_forker}'") do |pid, stdin, stdout, stderr| + end + end end.not_to raise_error end end @@ -92,10 +94,11 @@ describe Chef::Mixin::Command, :volatile do # btm # Serdar - During Solaris tests, we've seen that processes # are taking a long time to exit. Bumping timeout now to 10. - expect {Timeout.timeout(10) do - evil_forker = "exit if fork; 10.times { sleep 1}" - run_command(:command => "ruby -e '#{evil_forker}'") - end}.not_to raise_error + expect do + Timeout.timeout(10) do + evil_forker = "exit if fork; 10.times { sleep 1}" + run_command(:command => "ruby -e '#{evil_forker}'") + end end.not_to raise_error end end diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb index de72f6b935..c9a6e6e909 100644 --- a/spec/unit/mixin/homebrew_user_spec.rb +++ b/spec/unit/mixin/homebrew_user_spec.rb @@ -51,11 +51,11 @@ describe Chef::Mixin::HomebrewUser do let(:user) { nil } let(:brew_owner) { 2001 } let(:default_brew_path) { "/usr/local/bin/brew" } - let(:stat_double) { + let(:stat_double) do d = double() expect(d).to receive(:uid).and_return(brew_owner) d - } + end context "debug statement prints owner name" do diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index dcee123982..0cafb925c8 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -56,7 +56,7 @@ describe Chef::Mixin::ParamsValidate do end it "should allow you to check what kind_of? thing an argument is with kind_of" do - expect { + expect do @vo.validate( { :one => "string" }, { @@ -65,9 +65,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :one => "string" }, { @@ -76,11 +76,11 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should allow you to specify an argument is required with required" do - expect { + expect do @vo.validate( { :one => "string" }, { @@ -89,9 +89,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :two => "string" }, { @@ -100,9 +100,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) - expect { + expect do @vo.validate( { :two => "string" }, { @@ -111,11 +111,11 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error end it "should allow you to specify whether an object has a method with respond_to" do - expect { + expect do @vo.validate( { :one => @vo }, { @@ -124,9 +124,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :one => @vo }, { @@ -135,11 +135,11 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should allow you to specify whether an object has all the given methods with respond_to and an array" do - expect { + expect do @vo.validate( { :one => @vo }, { @@ -148,9 +148,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :one => @vo }, { @@ -159,7 +159,7 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should let you set a default value with default => value" do @@ -173,7 +173,7 @@ describe Chef::Mixin::ParamsValidate do end it "should let you check regular expressions" do - expect { + expect do @vo.validate( { :one => "is good" }, { @@ -182,9 +182,9 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :one => "is good" }, { @@ -193,44 +193,44 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should let you specify your own callbacks" do - expect { + expect do @vo.validate( { :one => "is good" }, { :one => { :callbacks => { - "should be equal to is good" => lambda { |a| + "should be equal to is good" => lambda do |a| a == "is good" - }, + end, }, }, } ) - }.not_to raise_error + end.not_to raise_error - expect { + expect do @vo.validate( { :one => "is bad" }, { :one => { :callbacks => { - "should be equal to 'is good'" => lambda { |a| + "should be equal to 'is good'" => lambda do |a| a == "is good" - }, + end, }, }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should let you combine checks" do args = { :one => "is good", :two => "is bad" } - expect { + expect do @vo.validate( args, { @@ -239,9 +239,9 @@ describe Chef::Mixin::ParamsValidate do :respond_to => [ :to_s, :upcase ], :regex => /^is good/, :callbacks => { - "should be your friend" => lambda { |a| + "should be your friend" => lambda do |a| a == "is good" - }, + end, }, :required => true, }, @@ -252,9 +252,9 @@ describe Chef::Mixin::ParamsValidate do :three => { :default => "neato mosquito" }, } ) - }.not_to raise_error + end.not_to raise_error expect(args[:three]).to eq("neato mosquito") - expect { + expect do @vo.validate( args, { @@ -263,9 +263,9 @@ describe Chef::Mixin::ParamsValidate do :respond_to => [ :to_s, :upcase ], :regex => /^is good/, :callbacks => { - "should be your friend" => lambda { |a| + "should be your friend" => lambda do |a| a == "is good" - }, + end, }, :required => true, }, @@ -276,11 +276,12 @@ describe Chef::Mixin::ParamsValidate do :three => { :default => "neato mosquito" }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should raise an ArgumentError if the validation map has an unknown check" do - expect { @vo.validate( + expect do + @vo.validate( { :one => "two" }, { :one => { @@ -288,17 +289,17 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should accept keys that are strings in the options" do - expect { + expect do @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ } }) - }.not_to raise_error + end.not_to raise_error end it "should allow an array to kind_of" do - expect { + expect do @vo.validate( { :one => "string" }, { @@ -307,8 +308,8 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error - expect { + end.not_to raise_error + expect do @vo.validate( { :one => ["string"] }, { @@ -317,8 +318,8 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.not_to raise_error - expect { + end.not_to raise_error + expect do @vo.validate( { :one => Hash.new }, { @@ -327,7 +328,7 @@ describe Chef::Mixin::ParamsValidate do }, } ) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "asserts that a value returns false from a predicate method" do @@ -354,15 +355,15 @@ describe Chef::Mixin::ParamsValidate do end it "should raise an ArgumentError when argument is nil and required is true" do - expect { + expect do @vo.set_or_return(:test, nil, { :required => true }) - }.to raise_error(ArgumentError) + end.to raise_error(ArgumentError) end it "should not raise an error when argument is nil and required is false" do - expect { + expect do @vo.set_or_return(:test, nil, { :required => false }) - }.not_to raise_error + end.not_to raise_error end it "should set and return @name, then return @name for foo when argument is nil" do diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb index eae5b033f1..8e5f3588ce 100644 --- a/spec/unit/mixin/powershell_out_spec.rb +++ b/spec/unit/mixin/powershell_out_spec.rb @@ -22,9 +22,9 @@ describe Chef::Mixin::PowershellOut do let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } } subject(:object) { shell_out_class.new } let(:architecture) { "something" } - let(:flags) { + let(:flags) do "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None" - } + end describe "#powershell_out" do it "runs a command and returns the shell_out object" do diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb index 7f2ecb94e2..6f52abccfb 100644 --- a/spec/unit/mixin/powershell_type_coercions_spec.rb +++ b/spec/unit/mixin/powershell_type_coercions_spec.rb @@ -27,12 +27,12 @@ end describe Chef::Mixin::PowershellTypeCoercions do let (:test_class) { Chef::PSTypeTester.new } - describe '#translate_type' do + describe "#translate_type" do it "single quotes a string" do expect(test_class.translate_type("foo")).to eq("'foo'") end - ["'", '"', '#', "`"].each do |c| + ["'", '"', "#", "`"].each do |c| it "base64 encodes a string that contains #{c}" do expect(test_class.translate_type("#{c}")).to match(Base64.strict_encode64(c)) end diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 191ea920c0..bf74ff410e 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -25,7 +25,7 @@ require "spec_helper" describe Chef::Mixin::ShellOut do let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } } subject(:shell_out_obj) { shell_out_class.new } - describe '#run_command_compatible_options' do + describe "#run_command_compatible_options" do subject { shell_out_obj.run_command_compatible_options(command_args) } let(:command_args) { [ cmd, options ] } let(:cmd) { "echo '#{rand(1000)}'" } diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb index 903c91164e..495ad0662c 100644 --- a/spec/unit/mixin/xml_escape_spec.rb +++ b/spec/unit/mixin/xml_escape_spec.rb @@ -37,7 +37,7 @@ describe Chef::Mixin::XMLEscape do end it "does not modify ASCII strings" do - expect(@escaper.xml_escape('foobarbaz!@#$%^*()')).to eq('foobarbaz!@#$%^*()') + expect(@escaper.xml_escape("foobarbaz!@\#$%^*()")).to eq("foobarbaz!@\#$%^*()") end it "converts invalid bytes to asterisks" do @@ -45,10 +45,10 @@ describe Chef::Mixin::XMLEscape do end it "converts UTF-8 correctly" do - expect(@escaper.xml_escape("\xC2\xA9")).to eq('©') + expect(@escaper.xml_escape("\xC2\xA9")).to eq("©") end it "converts win 1252 characters correctly" do - expect(@escaper.xml_escape("#{0x80.chr}")).to eq('€') + expect(@escaper.xml_escape("#{0x80.chr}")).to eq("€") end end |