beaker 4.40.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +13 -11
- data/Gemfile +12 -7
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +4 -3
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +93 -198
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -24
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +22 -27
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +169 -158
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -36
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +7 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
data/spec/beaker/command_spec.rb
CHANGED
@@ -2,163 +2,159 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Command do
|
5
|
-
subject(:cmd) { described_class.new(
|
5
|
+
subject(:cmd) { described_class.new(command, args, options) }
|
6
6
|
|
7
7
|
let(:command) { @command || '/bin/ls' }
|
8
|
-
let(:args) { @args ||
|
9
|
-
let(:options) { @options ||
|
8
|
+
let(:args) { @args || [] }
|
9
|
+
let(:options) { @options || {} }
|
10
10
|
|
11
|
-
let(:host)
|
12
|
-
h =
|
13
|
-
allow(
|
11
|
+
let(:host) do
|
12
|
+
h = {}
|
13
|
+
allow(h).to receive(:environment_string).and_return('')
|
14
14
|
h
|
15
|
-
|
15
|
+
end
|
16
16
|
|
17
17
|
it 'creates a new Command object' do
|
18
18
|
@command = '/usr/bin/blah'
|
19
|
-
@args = [
|
19
|
+
@args = %w[to the baz]
|
20
20
|
@options = { :foo => 'bar' }
|
21
21
|
|
22
|
-
expect(
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
|
26
|
-
expect( cmd.args_string ).to be == 'to the baz'
|
27
|
-
expect( cmd.options_string ).to be == '--foo=bar'
|
22
|
+
expect(cmd.options).to be == @options
|
23
|
+
expect(cmd.args).to be == @args
|
24
|
+
expect(cmd.command).to be == @command
|
28
25
|
|
26
|
+
expect(cmd.args_string).to be == 'to the baz'
|
27
|
+
expect(cmd.options_string).to be == '--foo=bar'
|
29
28
|
end
|
30
29
|
|
31
30
|
describe '#:prepend_cmds' do
|
32
31
|
it 'can prepend commands' do
|
33
32
|
@command = '/usr/bin/blah'
|
34
|
-
@args = [
|
33
|
+
@args = %w[to the baz]
|
35
34
|
@options = { :foo => 'bar' }
|
36
|
-
allow(
|
37
|
-
allow(
|
35
|
+
allow(host).to receive(:prepend_commands).and_return('aloha!')
|
36
|
+
allow(host).to receive(:append_commands).and_return('')
|
38
37
|
|
39
|
-
expect(
|
38
|
+
expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz"
|
40
39
|
end
|
41
40
|
|
42
41
|
it 'can handle no prepend_cmds' do
|
43
42
|
@command = '/usr/bin/blah'
|
44
|
-
@args = [
|
43
|
+
@args = %w[to the baz]
|
45
44
|
@options = { :foo => 'bar' }
|
46
|
-
allow(
|
47
|
-
allow(
|
45
|
+
allow(host).to receive(:prepend_commands).and_return('')
|
46
|
+
allow(host).to receive(:append_commands).and_return('')
|
48
47
|
|
49
|
-
expect(
|
48
|
+
expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
describe '#:append_commands' do
|
54
53
|
it 'can append commands' do
|
55
54
|
@command = '/usr/bin/blah'
|
56
|
-
@args = [
|
55
|
+
@args = %w[to the baz]
|
57
56
|
@options = { :foo => 'bar' }
|
58
|
-
allow(
|
59
|
-
allow(
|
57
|
+
allow(host).to receive(:prepend_commands).and_return('aloha!')
|
58
|
+
allow(host).to receive(:append_commands).and_return('moo cow')
|
60
59
|
|
61
|
-
expect(
|
60
|
+
expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz moo cow"
|
62
61
|
end
|
63
62
|
|
64
63
|
it 'can handle no append_cmds' do
|
65
64
|
@command = '/usr/bin/blah'
|
66
|
-
@args = [
|
65
|
+
@args = %w[to the baz]
|
67
66
|
@options = { :foo => 'bar' }
|
68
|
-
allow(
|
69
|
-
allow(
|
67
|
+
allow(host).to receive(:prepend_commands).and_return('')
|
68
|
+
allow(host).to receive(:append_commands).and_return('')
|
70
69
|
|
71
|
-
expect(
|
70
|
+
expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
74
|
describe '#options_string' do
|
76
75
|
it 'parses things' do
|
77
76
|
subject.options = { :v => nil, :test => nil,
|
78
|
-
:server => 'master', :a => 'answers.txt' }
|
79
|
-
expect(
|
80
|
-
expect(
|
81
|
-
expect(
|
82
|
-
expect(
|
77
|
+
:server => 'master', :a => 'answers.txt', }
|
78
|
+
expect(subject.options_string).to match(/-v/)
|
79
|
+
expect(subject.options_string).to match(/--test/)
|
80
|
+
expect(subject.options_string).to match(/--server=master/)
|
81
|
+
expect(subject.options_string).to match(/-a=answers\.txt/)
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
85
|
describe '#args_string' do
|
87
86
|
it 'joins an array' do
|
88
87
|
subject.args = ['my/command and', nil, 'its args and opts']
|
89
|
-
expect(
|
88
|
+
expect(subject.args_string).to be == 'my/command and its args and opts'
|
90
89
|
end
|
91
90
|
end
|
92
|
-
|
93
|
-
|
94
91
|
end
|
95
92
|
|
96
93
|
describe HostCommand do
|
97
|
-
subject(:cmd) { described_class.new(
|
94
|
+
subject(:cmd) { described_class.new(command, args, options) }
|
98
95
|
|
99
96
|
let(:command) { @command || '/bin/ls' }
|
100
|
-
let(:args) { @args ||
|
101
|
-
let(:options) { @options ||
|
97
|
+
let(:args) { @args || [] }
|
98
|
+
let(:options) { @options || {} }
|
102
99
|
|
103
|
-
let(:host) {
|
100
|
+
let(:host) { {} }
|
104
101
|
|
105
102
|
it 'returns a simple string passed in' do
|
106
103
|
@command = "pants"
|
107
|
-
expect(
|
104
|
+
expect(cmd.cmd_line host).to be === @command
|
108
105
|
end
|
109
106
|
|
110
107
|
it 'returns single quoted string correctly' do
|
111
108
|
@command = "str_p = 'pants'; str_p"
|
112
|
-
expect(
|
109
|
+
expect(cmd.cmd_line host).to be === @command
|
113
110
|
end
|
114
111
|
|
115
112
|
it 'returns empty strings when given the escaped version of the same' do
|
116
113
|
@command = "\"\""
|
117
|
-
expect(
|
114
|
+
expect(cmd.cmd_line host).to be === ""
|
118
115
|
end
|
119
116
|
end
|
120
117
|
|
121
118
|
describe SedCommand do
|
122
|
-
subject(:cmd) { described_class.new(
|
119
|
+
subject(:cmd) { described_class.new(platform, expression, filename, options) }
|
123
120
|
|
124
|
-
let(:host)
|
125
|
-
h =
|
126
|
-
allow(
|
127
|
-
allow(
|
128
|
-
allow(
|
121
|
+
let(:host) do
|
122
|
+
h = {}
|
123
|
+
allow(h).to receive(:environment_string).and_return('')
|
124
|
+
allow(h).to receive(:prepend_commands).and_return('')
|
125
|
+
allow(h).to receive(:append_commands).and_return('')
|
129
126
|
h
|
130
|
-
|
127
|
+
end
|
131
128
|
let(:platform) { @platform || 'unix' }
|
132
129
|
let(:expression) { @expression || 's/b/s/' }
|
133
130
|
let(:filename) { @filename || '/fakefile' }
|
134
|
-
let(:options) { @options ||
|
135
|
-
|
131
|
+
let(:options) { @options || {} }
|
136
132
|
|
137
133
|
it 'forms a basic sed command correctly' do
|
138
|
-
expect(
|
134
|
+
expect(cmd.cmd_line host).to be === "sed -i -e \"#{expression}\" #{filename}"
|
139
135
|
end
|
140
136
|
|
141
137
|
it 'provides the -i option to rewrite file in-place on non-solaris hosts' do
|
142
|
-
expect(
|
138
|
+
expect(cmd.cmd_line host).to include('-i')
|
143
139
|
end
|
144
140
|
|
145
141
|
describe 'on solaris hosts' do
|
146
142
|
it 'removes the -i option correctly' do
|
147
143
|
@platform = 'solaris'
|
148
|
-
expect(
|
144
|
+
expect(cmd.cmd_line host).not_to include('-i')
|
149
145
|
end
|
150
146
|
|
151
147
|
it 'deals with in-place file substitution correctly' do
|
152
148
|
@platform = 'solaris'
|
153
149
|
default_temp_file = "#{filename}.tmp"
|
154
|
-
expect(
|
150
|
+
expect(cmd.cmd_line host).to include(" > #{default_temp_file} && mv #{default_temp_file} #{filename} && rm -f #{default_temp_file}")
|
155
151
|
end
|
156
152
|
|
157
153
|
it 'allows you to provide the name of the temp file for in-place file substitution' do
|
158
154
|
@platform = 'solaris'
|
159
155
|
temp_file = 'mytemp.tmp'
|
160
156
|
@options = { :temp_file => temp_file }
|
161
|
-
expect(
|
157
|
+
expect(cmd.cmd_line host).to include(" > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}")
|
162
158
|
end
|
163
159
|
end
|
164
160
|
end
|
@@ -7,11 +7,11 @@ end
|
|
7
7
|
describe ClassMixedWithDSLAssertions do
|
8
8
|
describe '#assert_output' do
|
9
9
|
it 'defaults to checking stdout' do
|
10
|
-
stdout =
|
11
|
-
This should not have space infront of it
|
12
|
-
|
13
|
-
|
14
|
-
CONSOLE
|
10
|
+
stdout = <<~CONSOLE
|
11
|
+
This should not have space infront of it
|
12
|
+
While this should have two spaces infront of it
|
13
|
+
And this 3, all lines should be to stdout
|
14
|
+
CONSOLE
|
15
15
|
|
16
16
|
expectation = <<CONSOLE
|
17
17
|
This should not have space infront of it
|
@@ -20,30 +20,30 @@ CONSOLE
|
|
20
20
|
CONSOLE
|
21
21
|
|
22
22
|
result = double
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
expect(
|
26
|
-
expect(
|
23
|
+
expect(result).to receive(:nil?).at_least(:once).and_return(false)
|
24
|
+
expect(result).to receive(:stdout).and_return(stdout)
|
25
|
+
expect(result).to receive(:output).and_return(stdout)
|
26
|
+
expect(result).to receive(:stderr).and_return('')
|
27
27
|
|
28
|
-
expect(
|
28
|
+
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
29
29
|
expect { subject.assert_output expectation }.not_to raise_error
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'allows specifying stream markers' do
|
33
|
-
output =
|
34
|
-
This is on stdout
|
35
|
-
While this is on stderr
|
36
|
-
And THIS is again on stdout
|
37
|
-
OUTPUT
|
33
|
+
output = <<~OUTPUT
|
34
|
+
This is on stdout
|
35
|
+
While this is on stderr
|
36
|
+
And THIS is again on stdout
|
37
|
+
OUTPUT
|
38
38
|
|
39
|
-
stdout =
|
40
|
-
This is on stdout
|
41
|
-
And THIS is again on stdout
|
42
|
-
STDOUT
|
39
|
+
stdout = <<~STDOUT
|
40
|
+
This is on stdout
|
41
|
+
And THIS is again on stdout
|
42
|
+
STDOUT
|
43
43
|
|
44
|
-
stderr =
|
45
|
-
While this is on stderr
|
46
|
-
STDERR
|
44
|
+
stderr = <<~STDERR
|
45
|
+
While this is on stderr
|
46
|
+
STDERR
|
47
47
|
|
48
48
|
expectation = <<EXPECT
|
49
49
|
STDOUT> This is on stdout
|
@@ -52,22 +52,22 @@ STDERR
|
|
52
52
|
EXPECT
|
53
53
|
|
54
54
|
result = double
|
55
|
-
expect(
|
56
|
-
expect(
|
57
|
-
expect(
|
58
|
-
expect(
|
55
|
+
expect(result).to receive(:nil?).at_least(:once).and_return(false)
|
56
|
+
expect(result).to receive(:stdout).and_return(stdout)
|
57
|
+
expect(result).to receive(:output).and_return(output)
|
58
|
+
expect(result).to receive(:stderr).and_return(stderr)
|
59
59
|
|
60
|
-
expect(
|
60
|
+
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
61
61
|
expect { subject.assert_output expectation }.not_to raise_error
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'raises an approriate error when output does not match expectations' do
|
65
65
|
FakeFS.without do
|
66
|
-
output =
|
67
|
-
This is on stdout
|
68
|
-
Holy Crap, what HAPPENED!?!?!?
|
69
|
-
And THIS is again on stdout
|
70
|
-
OUTPUT
|
66
|
+
output = <<~OUTPUT
|
67
|
+
This is on stdout
|
68
|
+
Holy Crap, what HAPPENED!?!?!?
|
69
|
+
And THIS is again on stdout
|
70
|
+
OUTPUT
|
71
71
|
|
72
72
|
expectation = <<EXPECT
|
73
73
|
STDOUT> This is on stdout
|
@@ -75,11 +75,11 @@ OUTPUT
|
|
75
75
|
STDOUT> And THIS is again on stdout
|
76
76
|
EXPECT
|
77
77
|
result = double
|
78
|
-
expect(
|
79
|
-
expect(
|
78
|
+
expect(result).to receive(:nil?).at_least(:once).and_return(false)
|
79
|
+
expect(result).to receive(:output).and_return(output)
|
80
80
|
|
81
|
-
expect(
|
82
|
-
expect { subject.assert_output expectation }.to raise_error(
|
81
|
+
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
82
|
+
expect { subject.assert_output expectation }.to raise_error(MiniTest::Assertion)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|