beaker 4.38.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 +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- 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/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- 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 +7 -8
- 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 +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- 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 +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- 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 +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- 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 +3 -5
- 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 +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- 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 +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- 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 +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- 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 +29 -34
- 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 +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- 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 +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- 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 +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- 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 +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- 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/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/spec/beaker/command_spec.rb
CHANGED
@@ -2,153 +2,159 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Command do
|
5
|
+
subject(:cmd) { described_class.new(command, args, options) }
|
6
|
+
|
5
7
|
let(:command) { @command || '/bin/ls' }
|
6
|
-
let(:args) { @args ||
|
7
|
-
let(:options) { @options ||
|
8
|
-
|
9
|
-
let(:host)
|
10
|
-
h =
|
11
|
-
allow(
|
8
|
+
let(:args) { @args || [] }
|
9
|
+
let(:options) { @options || {} }
|
10
|
+
|
11
|
+
let(:host) do
|
12
|
+
h = {}
|
13
|
+
allow(h).to receive(:environment_string).and_return('')
|
12
14
|
h
|
13
|
-
|
15
|
+
end
|
14
16
|
|
15
17
|
it 'creates a new Command object' do
|
16
18
|
@command = '/usr/bin/blah'
|
17
|
-
@args = [
|
19
|
+
@args = %w[to the baz]
|
18
20
|
@options = { :foo => 'bar' }
|
19
21
|
|
20
|
-
expect(
|
21
|
-
expect(
|
22
|
-
expect(
|
23
|
-
|
24
|
-
expect( cmd.args_string ).to be == 'to the baz'
|
25
|
-
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
|
26
25
|
|
26
|
+
expect(cmd.args_string).to be == 'to the baz'
|
27
|
+
expect(cmd.options_string).to be == '--foo=bar'
|
27
28
|
end
|
28
29
|
|
29
30
|
describe '#:prepend_cmds' do
|
30
31
|
it 'can prepend commands' do
|
31
32
|
@command = '/usr/bin/blah'
|
32
|
-
@args = [
|
33
|
+
@args = %w[to the baz]
|
33
34
|
@options = { :foo => 'bar' }
|
34
|
-
allow(
|
35
|
-
allow(
|
35
|
+
allow(host).to receive(:prepend_commands).and_return('aloha!')
|
36
|
+
allow(host).to receive(:append_commands).and_return('')
|
36
37
|
|
37
|
-
expect(
|
38
|
+
expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz"
|
38
39
|
end
|
39
40
|
|
40
41
|
it 'can handle no prepend_cmds' do
|
41
42
|
@command = '/usr/bin/blah'
|
42
|
-
@args = [
|
43
|
+
@args = %w[to the baz]
|
43
44
|
@options = { :foo => 'bar' }
|
44
|
-
allow(
|
45
|
-
allow(
|
45
|
+
allow(host).to receive(:prepend_commands).and_return('')
|
46
|
+
allow(host).to receive(:append_commands).and_return('')
|
46
47
|
|
47
|
-
expect(
|
48
|
+
expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
52
|
describe '#:append_commands' do
|
52
53
|
it 'can append commands' do
|
53
54
|
@command = '/usr/bin/blah'
|
54
|
-
@args = [
|
55
|
+
@args = %w[to the baz]
|
55
56
|
@options = { :foo => 'bar' }
|
56
|
-
allow(
|
57
|
-
allow(
|
57
|
+
allow(host).to receive(:prepend_commands).and_return('aloha!')
|
58
|
+
allow(host).to receive(:append_commands).and_return('moo cow')
|
58
59
|
|
59
|
-
expect(
|
60
|
+
expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz moo cow"
|
60
61
|
end
|
61
62
|
|
62
63
|
it 'can handle no append_cmds' do
|
63
64
|
@command = '/usr/bin/blah'
|
64
|
-
@args = [
|
65
|
+
@args = %w[to the baz]
|
65
66
|
@options = { :foo => 'bar' }
|
66
|
-
allow(
|
67
|
-
allow(
|
67
|
+
allow(host).to receive(:prepend_commands).and_return('')
|
68
|
+
allow(host).to receive(:append_commands).and_return('')
|
68
69
|
|
69
|
-
expect(
|
70
|
+
expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
74
|
describe '#options_string' do
|
74
75
|
it 'parses things' do
|
75
76
|
subject.options = { :v => nil, :test => nil,
|
76
|
-
:server => 'master', :a => 'answers.txt' }
|
77
|
-
expect(
|
78
|
-
expect(
|
79
|
-
expect(
|
80
|
-
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/)
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
85
|
describe '#args_string' do
|
85
86
|
it 'joins an array' do
|
86
87
|
subject.args = ['my/command and', nil, 'its args and opts']
|
87
|
-
expect(
|
88
|
+
expect(subject.args_string).to be == 'my/command and its args and opts'
|
88
89
|
end
|
89
90
|
end
|
90
|
-
|
91
|
-
|
92
91
|
end
|
92
|
+
|
93
93
|
describe HostCommand do
|
94
|
+
subject(:cmd) { described_class.new(command, args, options) }
|
95
|
+
|
94
96
|
let(:command) { @command || '/bin/ls' }
|
95
|
-
let(:args) { @args ||
|
96
|
-
let(:options) { @options ||
|
97
|
-
|
98
|
-
let(:host) {
|
97
|
+
let(:args) { @args || [] }
|
98
|
+
let(:options) { @options || {} }
|
99
|
+
|
100
|
+
let(:host) { {} }
|
99
101
|
|
100
102
|
it 'returns a simple string passed in' do
|
101
103
|
@command = "pants"
|
102
|
-
expect(
|
104
|
+
expect(cmd.cmd_line host).to be === @command
|
103
105
|
end
|
106
|
+
|
104
107
|
it 'returns single quoted string correctly' do
|
105
108
|
@command = "str_p = 'pants'; str_p"
|
106
|
-
expect(
|
109
|
+
expect(cmd.cmd_line host).to be === @command
|
107
110
|
end
|
111
|
+
|
108
112
|
it 'returns empty strings when given the escaped version of the same' do
|
109
113
|
@command = "\"\""
|
110
|
-
expect(
|
114
|
+
expect(cmd.cmd_line host).to be === ""
|
111
115
|
end
|
112
116
|
end
|
117
|
+
|
113
118
|
describe SedCommand do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
allow(
|
119
|
+
subject(:cmd) { described_class.new(platform, expression, filename, options) }
|
120
|
+
|
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('')
|
119
126
|
h
|
120
|
-
|
127
|
+
end
|
121
128
|
let(:platform) { @platform || 'unix' }
|
122
129
|
let(:expression) { @expression || 's/b/s/' }
|
123
130
|
let(:filename) { @filename || '/fakefile' }
|
124
|
-
let(:options) { @options ||
|
125
|
-
subject(:cmd) { SedCommand.new( platform, expression, filename, options ) }
|
131
|
+
let(:options) { @options || {} }
|
126
132
|
|
127
133
|
it 'forms a basic sed command correctly' do
|
128
|
-
expect(
|
134
|
+
expect(cmd.cmd_line host).to be === "sed -i -e \"#{expression}\" #{filename}"
|
129
135
|
end
|
130
136
|
|
131
137
|
it 'provides the -i option to rewrite file in-place on non-solaris hosts' do
|
132
|
-
expect(
|
138
|
+
expect(cmd.cmd_line host).to include('-i')
|
133
139
|
end
|
134
140
|
|
135
141
|
describe 'on solaris hosts' do
|
136
142
|
it 'removes the -i option correctly' do
|
137
143
|
@platform = 'solaris'
|
138
|
-
expect(
|
144
|
+
expect(cmd.cmd_line host).not_to include('-i')
|
139
145
|
end
|
140
146
|
|
141
147
|
it 'deals with in-place file substitution correctly' do
|
142
148
|
@platform = 'solaris'
|
143
149
|
default_temp_file = "#{filename}.tmp"
|
144
|
-
expect(
|
150
|
+
expect(cmd.cmd_line host).to include(" > #{default_temp_file} && mv #{default_temp_file} #{filename} && rm -f #{default_temp_file}")
|
145
151
|
end
|
146
152
|
|
147
153
|
it 'allows you to provide the name of the temp file for in-place file substitution' do
|
148
154
|
@platform = 'solaris'
|
149
155
|
temp_file = 'mytemp.tmp'
|
150
156
|
@options = { :temp_file => temp_file }
|
151
|
-
expect(
|
157
|
+
expect(cmd.cmd_line host).to include(" > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}")
|
152
158
|
end
|
153
159
|
end
|
154
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(
|
29
|
-
expect { subject.assert_output expectation }.
|
28
|
+
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
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,31 +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(
|
61
|
-
expect { subject.assert_output expectation }.
|
60
|
+
expect(subject).to receive(:result).at_least(:once).and_return(result)
|
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
|
71
|
-
|
72
|
-
stdout = <<STDOUT
|
73
|
-
This is on stdout
|
74
|
-
And THIS is again on stdout
|
75
|
-
STDOUT
|
76
|
-
|
77
|
-
stderr = <<STDERR
|
78
|
-
Holy Crap, what HAPPENED!?!?!?
|
79
|
-
STDERR
|
66
|
+
output = <<~OUTPUT
|
67
|
+
This is on stdout
|
68
|
+
Holy Crap, what HAPPENED!?!?!?
|
69
|
+
And THIS is again on stdout
|
70
|
+
OUTPUT
|
80
71
|
|
81
72
|
expectation = <<EXPECT
|
82
73
|
STDOUT> This is on stdout
|
@@ -84,11 +75,11 @@ STDERR
|
|
84
75
|
STDOUT> And THIS is again on stdout
|
85
76
|
EXPECT
|
86
77
|
result = double
|
87
|
-
expect(
|
88
|
-
expect(
|
78
|
+
expect(result).to receive(:nil?).at_least(:once).and_return(false)
|
79
|
+
expect(result).to receive(:output).and_return(output)
|
89
80
|
|
90
|
-
expect(
|
91
|
-
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)
|
92
83
|
end
|
93
84
|
end
|
94
85
|
end
|