blob: aadc6d00cdaca84305c07c3a7705e7e800628094 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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
# this is a hash-like object
def __config
{}
end
# this is a train transport connection or nil
def __transport_connection
nil
end
# this is a logger-like object
def __log
Logger.new(IO::NULL)
end
end
let(:test_class) { TestClass.new }
it "works to run a trivial ruby command" do
expect(test_class.shell_out("ruby -e 'exit 0'")).to be_kind_of(Mixlib::ShellOut)
end
end
|