summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout/helper_spec.rb12
-rw-r--r--spec/mixlib/shellout_spec.rb6
-rw-r--r--spec/spec_helper.rb2
3 files changed, 15 insertions, 5 deletions
diff --git a/spec/mixlib/shellout/helper_spec.rb b/spec/mixlib/shellout/helper_spec.rb
index 0c67e51..8c1136d 100644
--- a/spec/mixlib/shellout/helper_spec.rb
+++ b/spec/mixlib/shellout/helper_spec.rb
@@ -2,6 +2,18 @@ require "spec_helper"
require "mixlib/shellout/helper"
require "logger"
+# to use this helper you need to either:
+# 1. use mixlib-log which has a trace level
+# 2. monkeypatch a trace level into ruby's logger like this
+# 3. override the __io_for_live_stream method
+#
+class Logger
+ module Severity; TRACE = -1; end
+ def trace(progname = nil, &block); add(TRACE, nil, progname, &block); end
+
+ def trace?; @level <= TRACE; end
+end
+
describe Mixlib::ShellOut::Helper, ruby: ">= 2.3" do
class TestClass
include Mixlib::ShellOut::Helper
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index b32a730..867644e 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -1110,7 +1110,7 @@ describe Mixlib::ShellOut do
end
after do
- @test_file.close if @test_file
+ @test_file&.close
end
let(:ruby_code) { "fd = File.for_fd(#{@test_file.to_i}) rescue nil; if fd; fd.seek(0); puts fd.read(5); end" }
@@ -1395,7 +1395,7 @@ describe Mixlib::ShellOut do
end
context "with subprocess writing lots of data to both stdout and stderr" do
- let(:expected_output_with) { lambda { |chr| (chr * 20_000) + (LINE_ENDING).to_s + (chr * 20_000) + (LINE_ENDING).to_s } }
+ let(:expected_output_with) { lambda { |chr| (chr * 20_000) + LINE_ENDING.to_s + (chr * 20_000) + LINE_ENDING.to_s } }
context "when writing to STDOUT first" do
let(:ruby_code) { %q{puts "f" * 20_000; STDERR.puts "u" * 20_000; puts "f" * 20_000; STDERR.puts "u" * 20_000} }
@@ -1558,7 +1558,7 @@ describe Mixlib::ShellOut do
let(:options) { { user: user } }
it "should run as specified user" do
- expect(running_user).to eql((user).to_s)
+ expect(running_user).to eql(user.to_s)
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fb60fe7..ebc5a84 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,3 @@
-$:.unshift File.expand_path("../../lib", __FILE__)
-$:.unshift File.expand_path("../..", __FILE__)
require "mixlib/shellout"
require "tmpdir"