Module: ShellTest::ShellMethods
- Includes:
- EnvMethods, StringMethods
- Included in:
- ShellTest
- Defined in:
- lib/shell_test/shell_methods.rb,
lib/shell_test/shell_methods/agent.rb,
lib/shell_test/shell_methods/timer.rb,
lib/shell_test/shell_methods/utils.rb,
lib/shell_test/shell_methods/session.rb
Defined Under Namespace
Modules: Utils
Classes: Agent, Session, Timer
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from EnvMethods
set_env, with_env
#_assert_str_equal, #_assert_str_match, #assert_str_equal, #assert_str_match, #expand_ctrl_chars, #indent, #outdent, #whitespace_escape
Instance Attribute Details
#original_env ⇒ Object
Returns the value of attribute original_env.
11
12
13
|
# File 'lib/shell_test/shell_methods.rb', line 11
def original_env
@original_env
end
|
Instance Method Details
#_assert_script(script, options = {}) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/shell_test/shell_methods.rb', line 37
def _assert_script(script, options={})
pty = _pty(script, options) do |session, expected, actual|
expected = expand_ctrl_chars(expected)
actual = expand_ctrl_chars(actual)
_assert_str_equal expected, actual do
session.summary %Q{
%s (elapsed: %.2fs max: %.2fs)
=========================================================
%s
-------------------- expected output --------------------
#{whitespace_escape(expected)}
------------------------ but was ------------------------
#{whitespace_escape(actual)}
=========================================================
}
end
end
if status = options[:exitstatus]
assert_equal(status, pty.status.exitstatus)
end
end
|
#_assert_script_match(script, options = {}) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/shell_test/shell_methods.rb', line 65
def _assert_script_match(script, options={})
pty = _pty(script, options) do |session, expected, actual|
expected = expand_ctrl_chars(expected)
actual = expand_ctrl_chars(actual)
_assert_str_match expected, actual do
session.summary %Q{
%s (%.2f:%.2fs)
=========================================================
%s
----------------- expected output like ------------------
#{whitespace_escape(expected)}
------------------------ but was ------------------------
#{whitespace_escape(actual)}
=========================================================
}
end
end
if status = options[:exitstatus]
assert_equal(status, pty.status.exitstatus)
end
end
|
#_pty(script, options = {}, &block) ⇒ Object
27
28
29
30
31
|
# File 'lib/shell_test/shell_methods.rb', line 27
def _pty(script, options={}, &block)
session = Session.new(options)
session.parse(script, options, &block)
session.run
end
|
#assert_script(script, options = {}) ⇒ Object
33
34
35
|
# File 'lib/shell_test/shell_methods.rb', line 33
def assert_script(script, options={})
_assert_script outdent(script), options
end
|
#assert_script_match(script, options = {}) ⇒ Object
61
62
63
|
# File 'lib/shell_test/shell_methods.rb', line 61
def assert_script_match(script, options={})
_assert_script_match outdent(script), options
end
|
#pty(script, options = {}, &block) ⇒ Object
23
24
25
|
# File 'lib/shell_test/shell_methods.rb', line 23
def pty(script, options={}, &block)
_pty outdent(script), options, &block
end
|
#setup ⇒ Object
13
14
15
16
|
# File 'lib/shell_test/shell_methods.rb', line 13
def setup
super
@original_env = set_env('PS1' => '$ ', 'PS2' => '> ')
end
|
#teardown ⇒ Object
18
19
20
21
|
# File 'lib/shell_test/shell_methods.rb', line 18
def teardown
set_env(@original_env)
super
end
|