obfusk-util 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -12
- data/lib/obfusk/util/sh.rb +50 -41
- data/lib/obfusk/util/version.rb +1 -1
- data/spec/obfusk/util/sh_spec.rb +129 -118
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf7375bb3b37224db96e59696194cd81e6a1abc
|
4
|
+
data.tar.gz: d9c148f1ba2b5fefd2e93012ee18a1126a0db3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee94a5abc89f7cfb162210ea6336cf9dbdc227ef52fb65075a1a126fd5b9bdbda777085a02766d01d551aa09ea8ee26066c1969534098d533c37c59fad4c928
|
7
|
+
data.tar.gz: dfc6216044f4b197ef8c527df107c2743b87f5145c450d46ccc08c0419ab6c2b5f6c71bce3b557058128f937e732855ee223eb9fa344dd2bdaf4d9c84c5d4b8f
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Date : 2014-02-20
|
6
6
|
|
7
7
|
Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
-
Version : v0.
|
8
|
+
Version : v0.5.0
|
9
9
|
|
10
10
|
[]: }}}1
|
11
11
|
|
@@ -197,25 +197,28 @@ end
|
|
197
197
|
```ruby
|
198
198
|
require 'obfusk/util/sh'
|
199
199
|
|
200
|
-
Obfusk::Util::sh
|
200
|
+
Obfusk::Util::sh 'echo "$0" ">>$1<<" ">>$FOO<<"', '"one"', 'FOO' => 'foo'
|
201
|
+
# stdout: bash >>"one"<< >>foo<<
|
202
|
+
|
203
|
+
Obfusk::Util::sh? 'false'
|
204
|
+
# => false
|
205
|
+
|
206
|
+
Obfusk::Util::sh! 'echo FOO; false'
|
207
|
+
# stdout: FOO
|
208
|
+
# => RunError
|
209
|
+
|
210
|
+
Obfusk::Util::shc('echo "$0" ">>$1<<" ">>$FOO<<"',
|
201
211
|
'"one"', 'FOO' => 'foo').stdout
|
202
212
|
# => %Q{bash >>"one"<< >>foo<<}
|
203
213
|
|
204
|
-
Obfusk::Util::
|
214
|
+
Obfusk::Util::shc('echo step1; false; echo step3',
|
205
215
|
print: true, exit: true, merge: true).stdout
|
206
216
|
# => "+ echo step1\nstep1\n+ false\n"
|
207
217
|
|
208
|
-
Obfusk::Util::
|
218
|
+
Obfusk::Util::shc? 'false'
|
209
219
|
# => false
|
210
220
|
|
211
|
-
Obfusk::Util::
|
212
|
-
# => RunError
|
213
|
-
|
214
|
-
Obfusk::Util::sys 'echo "$0" ">>$1<<" ">>$FOO<<"', '"one"', 'FOO' => 'foo'
|
215
|
-
# stdout: bash >>"one"<< >>foo<<
|
216
|
-
|
217
|
-
Obfusk::Util::sys! 'echo FOO; false'
|
218
|
-
# stdout: FOO
|
221
|
+
Obfusk::Util::shc! 'false'
|
219
222
|
# => RunError
|
220
223
|
|
221
224
|
```
|
data/lib/obfusk/util/sh.rb
CHANGED
@@ -14,8 +14,8 @@ require 'obfusk/util/run'
|
|
14
14
|
# my namespace
|
15
15
|
module Obfusk; module Util
|
16
16
|
|
17
|
-
#
|
18
|
-
|
17
|
+
# common methods for Sh, Shc
|
18
|
+
module ShBase # {{{1
|
19
19
|
|
20
20
|
# was the exitstatus zero?
|
21
21
|
def ok?
|
@@ -32,14 +32,24 @@ module Obfusk; module Util
|
|
32
32
|
|
33
33
|
end # }}}1
|
34
34
|
|
35
|
+
# shell result
|
36
|
+
class Sh < Struct.new(:cmd, :status)
|
37
|
+
include ShBase
|
38
|
+
end
|
39
|
+
|
40
|
+
# shell capture result
|
41
|
+
class Shc < Struct.new(:cmd, :status, :stdout, :stderr)
|
42
|
+
include ShBase
|
43
|
+
end
|
44
|
+
|
35
45
|
# --
|
36
46
|
|
37
|
-
# run a command using bash (w/ arguments)
|
38
|
-
#
|
47
|
+
# run a command using bash (w/ arguments); see also {shc}; uses
|
48
|
+
# {spawn_w}
|
39
49
|
#
|
40
50
|
# ```
|
41
|
-
# sh
|
42
|
-
# #
|
51
|
+
# sh 'echo "$0" ">>$1<<" ">>$FOO<<"', '"one"', 'FOO' => 'foo'
|
52
|
+
# # stdout: bash >>"one"<< >>foo<<
|
43
53
|
# ```
|
44
54
|
#
|
45
55
|
# @param [Hash] args.last
|
@@ -51,15 +61,11 @@ module Obfusk; module Util
|
|
51
61
|
# * any other `String` key is added to the `env`
|
52
62
|
# * any other `Symbol` key is passed as an option to `capture3`
|
53
63
|
# @return [Sh]
|
54
|
-
def self.sh(cmd, *args)
|
55
|
-
c
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
stdout, stderr, status = capture3(*c[:cmd], c[:opts])
|
60
|
-
end
|
61
|
-
Sh.new c[:cmd], status, stdout, stderr
|
62
|
-
end # }}}1
|
64
|
+
def self.sh(cmd, *args)
|
65
|
+
c = _sh cmd, args; o = c[:opts]
|
66
|
+
o_ = c[:merge] ? o.merge(:err => o[:out] ? [:child, :out] : :out) : o
|
67
|
+
Sh.new c[:cmd], spawn_w(*c[:cmd], o_)
|
68
|
+
end
|
63
69
|
|
64
70
|
# `sh(...).ok?`
|
65
71
|
def self.sh?(cmd, *args)
|
@@ -73,30 +79,33 @@ module Obfusk; module Util
|
|
73
79
|
|
74
80
|
# --
|
75
81
|
|
76
|
-
# run a command using bash (w/ arguments)
|
77
|
-
# as
|
82
|
+
# run a command using bash (w/ arguments) and capture its stdout and
|
83
|
+
# stderr; accepts the same arguments as {sh}; uses `capture{2e,3}`
|
78
84
|
#
|
79
85
|
# ```
|
80
|
-
#
|
81
|
-
# #
|
86
|
+
# shc('echo "$0" ">>$1<<" ">>$FOO<<"', '"one"', 'FOO' => 'foo').stdout
|
87
|
+
# # => %Q{bash >>"one"<< >>foo<<}
|
82
88
|
# ```
|
83
89
|
#
|
84
|
-
# @return [
|
85
|
-
def self.
|
86
|
-
c
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
+
# @return [Shc]
|
91
|
+
def self.shc(cmd, *args) # {{{1
|
92
|
+
c = _sh cmd, args
|
93
|
+
if c[:merge]
|
94
|
+
stderr = nil; stdout, status = capture2e(*c[:cmd], c[:opts])
|
95
|
+
else
|
96
|
+
stdout, stderr, status = capture3(*c[:cmd], c[:opts])
|
97
|
+
end
|
98
|
+
Shc.new c[:cmd], status, stdout, stderr
|
99
|
+
end # }}}1
|
90
100
|
|
91
|
-
# `
|
92
|
-
def self.
|
93
|
-
|
101
|
+
# `shc(...).ok?`
|
102
|
+
def self.shc?(cmd, *args)
|
103
|
+
shc(cmd, *args).ok?
|
94
104
|
end
|
95
105
|
|
96
|
-
# `
|
97
|
-
|
98
|
-
|
99
|
-
sys(cmd, *args).tap { |s| chk_exitstatus cmd, s.exitstatus }
|
106
|
+
# `shc(...).ok!`
|
107
|
+
def self.shc!(cmd, *args)
|
108
|
+
shc(cmd, *args).ok!
|
100
109
|
end
|
101
110
|
|
102
111
|
# --
|
@@ -118,19 +127,19 @@ module Obfusk; module Util
|
|
118
127
|
|
119
128
|
# --
|
120
129
|
|
121
|
-
# ohai +
|
122
|
-
def self.
|
123
|
-
::Obfusk::Util.ohai _spawn_rm_opts(args)*' ';
|
130
|
+
# ohai + shc; requires `obfusk/util/message`
|
131
|
+
def self.oshc(*args)
|
132
|
+
::Obfusk::Util.ohai _spawn_rm_opts(args)*' '; shc(*args)
|
124
133
|
end
|
125
134
|
|
126
|
-
# ohai +
|
127
|
-
def self.
|
128
|
-
::Obfusk::Util.ohai _spawn_rm_opts(args)*' ';
|
135
|
+
# ohai + shc?; requires `obfusk/util/message`
|
136
|
+
def self.oshc?(*args)
|
137
|
+
::Obfusk::Util.ohai _spawn_rm_opts(args)*' '; shc?(*args)
|
129
138
|
end
|
130
139
|
|
131
|
-
# ohai +
|
132
|
-
def self.
|
133
|
-
::Obfusk::Util.ohai _spawn_rm_opts(args)*' ';
|
140
|
+
# ohai + shc!; requires `obfusk/util/message`
|
141
|
+
def self.oshc!(*args)
|
142
|
+
::Obfusk::Util.ohai _spawn_rm_opts(args)*' '; shc!(*args)
|
134
143
|
end
|
135
144
|
|
136
145
|
# --
|
data/lib/obfusk/util/version.rb
CHANGED
data/spec/obfusk/util/sh_spec.rb
CHANGED
@@ -17,87 +17,100 @@ describe 'obfusk/util/sh' do
|
|
17
17
|
|
18
18
|
context 'sh (1)' do # {{{1
|
19
19
|
it 'echoes w/ args and env' do
|
20
|
-
r =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
expect(
|
20
|
+
r, w = IO.pipe
|
21
|
+
res = ou.sh 'echo "$0" ">>$1<<" ">>$FOO<<"', '"one"',
|
22
|
+
'FOO' => 'foo', out: w
|
23
|
+
w.close; x = r.read; r.close
|
24
|
+
expect(res.ok?).to eq(true)
|
25
|
+
expect(x).to eq(%Q{bash >>"one"<< >>foo<<\n})
|
25
26
|
end
|
26
27
|
it 'works w/ print, exit, and merge' do
|
27
|
-
r =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
expect(
|
28
|
+
r, w = IO.pipe
|
29
|
+
res = ou.sh 'echo step1; false; echo step3', print: true, exit: true,
|
30
|
+
merge: true, out: w
|
31
|
+
w.close; x = r.read; r.close
|
32
|
+
expect(res.ok?).to eq(false)
|
33
|
+
expect(x).to eq("+ echo step1\nstep1\n+ false\n")
|
32
34
|
end
|
33
35
|
it 'outputs pwd w/ arg' do
|
34
|
-
r =
|
35
|
-
|
36
|
-
|
37
|
-
expect(
|
36
|
+
r, w = IO.pipe
|
37
|
+
res = ou.sh 'cd "$1"; pwd', '/', out: w
|
38
|
+
w.close; x = r.read; r.close
|
39
|
+
expect(res.ok?).to eq(true)
|
40
|
+
expect(x).to eq("/\n")
|
38
41
|
end
|
39
42
|
it 'outputs pwd w/ :chdir' do
|
40
|
-
r =
|
41
|
-
|
42
|
-
|
43
|
-
expect(
|
43
|
+
r, w = IO.pipe
|
44
|
+
res = ou.sh 'pwd', chdir: '/', out: w
|
45
|
+
w.close; x = r.read; r.close
|
46
|
+
expect(res.ok?).to eq(true)
|
47
|
+
expect(x).to eq("/\n")
|
44
48
|
end
|
45
49
|
end # }}}1
|
46
50
|
|
47
51
|
context 'sh (2)' do # {{{1
|
48
52
|
it 'prints to stderr w/ print/-x' do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
ro, wo = IO.pipe; re, we = IO.pipe
|
54
|
+
res = ou.sh 'echo FOO; echo BAR', print: true, out: wo, err: we
|
55
|
+
wo.close; o = ro.read; ro.close
|
56
|
+
we.close; e = re.read; re.close
|
57
|
+
expect(res.ok?).to eq(true)
|
58
|
+
expect(o).to eq("FOO\nBAR\n")
|
59
|
+
expect(e).to eq("+ echo FOO\n+ echo BAR\n")
|
53
60
|
end
|
54
61
|
it 'ignores false w/o exit/-e' do
|
55
|
-
r =
|
56
|
-
|
57
|
-
|
58
|
-
expect(
|
62
|
+
r, w = IO.pipe
|
63
|
+
res = ou.sh 'echo FOO; false; echo BAR', out: w
|
64
|
+
w.close; x = r.read; r.close
|
65
|
+
expect(res.ok?).to eq(true)
|
66
|
+
expect(x).to eq("FOO\nBAR\n")
|
59
67
|
end
|
60
68
|
it 'stops at false w/ exit/-e' do
|
61
|
-
r =
|
62
|
-
|
63
|
-
|
64
|
-
expect(
|
69
|
+
r, w = IO.pipe
|
70
|
+
res = ou.sh 'echo FOO; false; echo BAR', exit: true, out: w
|
71
|
+
w.close; x = r.read; r.close
|
72
|
+
expect(res.ok?).to eq(false)
|
73
|
+
expect(x).to eq("FOO\n")
|
65
74
|
end
|
66
75
|
it 'merges stdout and stderr w/ merge' do
|
67
|
-
r =
|
68
|
-
|
69
|
-
|
70
|
-
expect(
|
76
|
+
r, w = IO.pipe
|
77
|
+
res = ou.sh 'echo FOO; echo BAR >&2; echo BAZ', merge: true, out: w
|
78
|
+
w.close; x = r.read; r.close
|
79
|
+
expect(res.ok?).to eq(true)
|
80
|
+
expect(x).to eq("FOO\nBAR\nBAZ\n")
|
71
81
|
end
|
72
82
|
it 'merges env w/ string keys' do
|
73
|
-
r =
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
expect(
|
83
|
+
r, w = IO.pipe
|
84
|
+
res = ou.sh 'echo $FOO; echo $BAR',
|
85
|
+
env: { 'FOO' => 'no', 'BAR' => 'bar' }, 'FOO' => 'yes', out: w
|
86
|
+
w.close; x = r.read; r.close
|
87
|
+
expect(res.ok?).to eq(true)
|
88
|
+
expect(x).to eq("yes\nbar\n")
|
78
89
|
end
|
79
90
|
end # }}}1
|
80
91
|
|
81
92
|
context 'sh (3)' do # {{{1
|
82
93
|
it 'false => ok? returns false and ok! raises' do
|
83
|
-
r =
|
84
|
-
|
85
|
-
|
86
|
-
expect
|
94
|
+
r, w = IO.pipe
|
95
|
+
res = ou.sh 'false', out: w
|
96
|
+
w.close; x = r.read; r.close
|
97
|
+
expect(res.ok?).to eq(false)
|
98
|
+
expect(res.status.exitstatus).to eq(1)
|
99
|
+
expect { res.ok! } .to \
|
87
100
|
raise_error(ou::RunError, /command returned non-zero/)
|
88
|
-
expect(
|
89
|
-
expect(r.stderr).to eq('')
|
101
|
+
expect(x).to eq('')
|
90
102
|
end
|
91
103
|
it 'fails w/ message on stderr w/ NONEXISTENT' do
|
92
|
-
r =
|
93
|
-
|
94
|
-
|
95
|
-
expect(
|
96
|
-
expect(
|
104
|
+
r, w = IO.pipe
|
105
|
+
res = ou.sh 'NONEXISTENT', err: w
|
106
|
+
w.close; x = r.read; r.close
|
107
|
+
expect(res.ok?).to eq(false)
|
108
|
+
expect(res.status.exitstatus).to eq(127)
|
109
|
+
expect(x).to eq("bash: NONEXISTENT: command not found\n")
|
97
110
|
end
|
98
111
|
it 'fails w/ RunError w/ shell NONEXISTENT' do
|
99
112
|
expect { ou.sh 'irrelevant', shell: 'NONEXISTENT' } .to \
|
100
|
-
raise_error(ou::RunError, /failed to
|
113
|
+
raise_error(ou::RunError, /failed to spawn command/)
|
101
114
|
end
|
102
115
|
end # }}}1
|
103
116
|
|
@@ -120,109 +133,107 @@ describe 'obfusk/util/sh' do
|
|
120
133
|
end
|
121
134
|
end # }}}1
|
122
135
|
|
123
|
-
context '
|
136
|
+
context 'shc (1)' do # {{{1
|
124
137
|
it 'echoes w/ args and env' do
|
125
|
-
r
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
expect(
|
130
|
-
expect(x).to eq(%Q{bash >>"one"<< >>foo<<\n})
|
138
|
+
r = ou.shc 'echo "$0" ">>$1<<" ">>$FOO<<"', '"one"',
|
139
|
+
'FOO' => 'foo'
|
140
|
+
expect(r.ok?).to eq(true)
|
141
|
+
expect(r.stdout).to eq(%Q{bash >>"one"<< >>foo<<\n})
|
142
|
+
expect(r.stderr).to eq('')
|
131
143
|
end
|
132
144
|
it 'works w/ print, exit, and merge' do
|
133
|
-
r,
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
expect(
|
138
|
-
expect(x).to eq("+ echo step1\nstep1\n+ false\n")
|
145
|
+
r = ou.shc 'echo step1; false; echo step3', print: true, exit: true,
|
146
|
+
merge: true
|
147
|
+
expect(r.ok?).to eq(false)
|
148
|
+
expect(r.stdout).to eq("+ echo step1\nstep1\n+ false\n")
|
149
|
+
expect(r.stderr).to eq(nil)
|
139
150
|
end
|
140
151
|
it 'outputs pwd w/ arg' do
|
141
|
-
r
|
142
|
-
|
143
|
-
|
144
|
-
expect(
|
145
|
-
expect(x).to eq("/\n")
|
152
|
+
r = ou.shc 'cd "$1"; pwd', '/'
|
153
|
+
expect(r.ok?).to eq(true)
|
154
|
+
expect(r.stdout).to eq("/\n")
|
155
|
+
expect(r.stderr).to eq('')
|
146
156
|
end
|
147
157
|
it 'outputs pwd w/ :chdir' do
|
148
|
-
r
|
149
|
-
|
150
|
-
|
151
|
-
expect(
|
152
|
-
expect(x).to eq("/\n")
|
158
|
+
r = ou.shc 'pwd', chdir: '/'
|
159
|
+
expect(r.ok?).to eq(true)
|
160
|
+
expect(r.stdout).to eq("/\n")
|
161
|
+
expect(r.stderr).to eq('')
|
153
162
|
end
|
154
163
|
end # }}}1
|
155
164
|
|
156
|
-
context '
|
165
|
+
context 'shc (2)' do # {{{1
|
157
166
|
it 'prints to stderr w/ print/-x' do
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
expect(res.exitstatus).to eq(0)
|
163
|
-
expect(o).to eq("FOO\nBAR\n")
|
164
|
-
expect(e).to eq("+ echo FOO\n+ echo BAR\n")
|
167
|
+
r = ou.shc 'echo FOO; echo BAR', print: true
|
168
|
+
expect(r.ok?).to eq(true)
|
169
|
+
expect(r.stdout).to eq("FOO\nBAR\n")
|
170
|
+
expect(r.stderr).to eq("+ echo FOO\n+ echo BAR\n")
|
165
171
|
end
|
166
172
|
it 'ignores false w/o exit/-e' do
|
167
|
-
r
|
168
|
-
|
169
|
-
|
170
|
-
expect(
|
171
|
-
expect(x).to eq("FOO\nBAR\n")
|
173
|
+
r = ou.shc 'echo FOO; false; echo BAR'
|
174
|
+
expect(r.ok?).to eq(true)
|
175
|
+
expect(r.stdout).to eq("FOO\nBAR\n")
|
176
|
+
expect(r.stderr).to eq('')
|
172
177
|
end
|
173
178
|
it 'stops at false w/ exit/-e' do
|
174
|
-
r
|
175
|
-
|
176
|
-
|
177
|
-
expect(
|
178
|
-
expect(x).to eq("FOO\n")
|
179
|
+
r = ou.shc 'echo FOO; false; echo BAR', exit: true
|
180
|
+
expect(r.ok?).to eq(false)
|
181
|
+
expect(r.stdout).to eq("FOO\n")
|
182
|
+
expect(r.stderr).to eq('')
|
179
183
|
end
|
180
184
|
it 'merges stdout and stderr w/ merge' do
|
181
|
-
r
|
182
|
-
|
183
|
-
|
184
|
-
expect(
|
185
|
-
expect(x).to eq("FOO\nBAR\nBAZ\n")
|
185
|
+
r = ou.shc 'echo FOO; echo BAR >&2; echo BAZ', merge: true
|
186
|
+
expect(r.ok?).to eq(true)
|
187
|
+
expect(r.stdout).to eq("FOO\nBAR\nBAZ\n")
|
188
|
+
expect(r.stderr).to eq(nil)
|
186
189
|
end
|
187
190
|
it 'merges env w/ string keys' do
|
188
|
-
r
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
expect(
|
193
|
-
expect(x).to eq("yes\nbar\n")
|
191
|
+
r = ou.shc 'echo $FOO; echo $BAR',
|
192
|
+
env: { 'FOO' => 'no', 'BAR' => 'bar' }, 'FOO' => 'yes'
|
193
|
+
expect(r.ok?).to eq(true)
|
194
|
+
expect(r.stdout).to eq("yes\nbar\n")
|
195
|
+
expect(r.stderr).to eq('')
|
194
196
|
end
|
195
197
|
end # }}}1
|
196
198
|
|
197
|
-
context '
|
199
|
+
context 'shc (3)' do # {{{1
|
200
|
+
it 'false => ok? returns false and ok! raises' do
|
201
|
+
r = ou.shc 'false'
|
202
|
+
expect(r.ok?).to eq(false)
|
203
|
+
expect(r.status.exitstatus).to eq(1)
|
204
|
+
expect { r.ok! } .to \
|
205
|
+
raise_error(ou::RunError, /command returned non-zero/)
|
206
|
+
expect(r.stdout).to eq('')
|
207
|
+
expect(r.stderr).to eq('')
|
208
|
+
end
|
198
209
|
it 'fails w/ message on stderr w/ NONEXISTENT' do
|
199
|
-
r
|
200
|
-
|
201
|
-
|
202
|
-
expect(
|
203
|
-
expect(
|
210
|
+
r = ou.shc 'NONEXISTENT'
|
211
|
+
expect(r.ok?).to eq(false)
|
212
|
+
expect(r.status.exitstatus).to eq(127)
|
213
|
+
expect(r.stdout).to eq('')
|
214
|
+
expect(r.stderr).to eq("bash: NONEXISTENT: command not found\n")
|
204
215
|
end
|
205
216
|
it 'fails w/ RunError w/ shell NONEXISTENT' do
|
206
|
-
expect { ou.
|
207
|
-
raise_error(ou::RunError, /failed to
|
217
|
+
expect { ou.shc 'irrelevant', shell: 'NONEXISTENT' } .to \
|
218
|
+
raise_error(ou::RunError, /failed to capture3 command/)
|
208
219
|
end
|
209
220
|
end # }}}1
|
210
221
|
|
211
|
-
context '
|
222
|
+
context 'shc?' do # {{{1
|
212
223
|
it 'true => true' do
|
213
|
-
expect(ou.
|
224
|
+
expect(ou.shc? 'true').to eq(true)
|
214
225
|
end
|
215
226
|
it 'false => false' do
|
216
|
-
expect(ou.
|
227
|
+
expect(ou.shc? 'false').to eq(false)
|
217
228
|
end
|
218
229
|
end # }}}1
|
219
230
|
|
220
|
-
context '
|
221
|
-
it 'true =>
|
222
|
-
expect( ou.
|
231
|
+
context 'shc!' do # {{{1
|
232
|
+
it 'true => Shc' do
|
233
|
+
expect( ou.shc! 'true' ).to be_an_instance_of(ou::Shc)
|
223
234
|
end
|
224
235
|
it 'false => RunError' do
|
225
|
-
expect { ou.
|
236
|
+
expect { ou.shc! 'false' } .to \
|
226
237
|
raise_error(ou::RunError, /command returned non-zero/)
|
227
238
|
end
|
228
239
|
end # }}}1
|