winrm 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -10
- data/.rspec +3 -3
- data/.travis.yml +12 -12
- data/Gemfile +9 -9
- data/LICENSE +202 -202
- data/README.md +213 -194
- data/Rakefile +36 -36
- data/Vagrantfile +9 -9
- data/WinrmAppveyor.psm1 +32 -0
- data/appveyor.yml +51 -42
- data/bin/rwinrm +97 -97
- data/changelog.md +3 -0
- data/lib/winrm.rb +42 -42
- data/lib/winrm/command_executor.rb +6 -2
- data/lib/winrm/command_output_decoder.rb +53 -53
- data/lib/winrm/exceptions/exceptions.rb +57 -57
- data/lib/winrm/helpers/iso8601_duration.rb +58 -58
- data/lib/winrm/helpers/powershell_script.rb +42 -42
- data/lib/winrm/http/response_handler.rb +82 -82
- data/lib/winrm/http/transport.rb +17 -0
- data/lib/winrm/output.rb +43 -43
- data/lib/winrm/soap_provider.rb +39 -39
- data/lib/winrm/version.rb +1 -1
- data/lib/winrm/winrm_service.rb +550 -547
- data/preamble +17 -17
- data/spec/auth_timeout_spec.rb +16 -16
- data/spec/cmd_spec.rb +102 -102
- data/spec/command_executor_spec.rb +27 -10
- data/spec/command_output_decoder_spec.rb +37 -37
- data/spec/config-example.yml +19 -19
- data/spec/exception_spec.rb +50 -50
- data/spec/issue_184_spec.rb +67 -67
- data/spec/issue_59_spec.rb +23 -23
- data/spec/matchers.rb +74 -74
- data/spec/output_spec.rb +110 -110
- data/spec/powershell_spec.rb +97 -97
- data/spec/response_handler_spec.rb +59 -59
- data/spec/spec_helper.rb +73 -73
- data/spec/stubs/responses/get_command_output_response.xml.erb +13 -13
- data/spec/stubs/responses/open_shell_v1.xml +19 -19
- data/spec/stubs/responses/open_shell_v2.xml +20 -20
- data/spec/stubs/responses/soap_fault_v1.xml +36 -36
- data/spec/stubs/responses/soap_fault_v2.xml +42 -42
- data/spec/stubs/responses/wmi_error_v2.xml +41 -41
- data/spec/transport_spec.rb +139 -124
- data/spec/winrm_options_spec.rb +76 -76
- data/spec/winrm_primitives_spec.rb +51 -51
- data/spec/wql_spec.rb +14 -14
- data/winrm.gemspec +40 -40
- metadata +4 -3
data/spec/issue_184_spec.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'winrm/winrm_service'
|
3
|
-
require 'rexml/document'
|
4
|
-
require 'erb'
|
5
|
-
require 'base64'
|
6
|
-
|
7
|
-
describe 'issue 184', unit: true do
|
8
|
-
let(:shell_id) { 'shell-123' }
|
9
|
-
let(:command_id) { 123 }
|
10
|
-
let(:test_data_xml_template) do
|
11
|
-
ERB.new(File.read('spec/stubs/responses/get_command_output_response.xml.erb'))
|
12
|
-
end
|
13
|
-
let(:service) do
|
14
|
-
WinRM::WinRMWebService.new(
|
15
|
-
'http://dummy/wsman',
|
16
|
-
:plaintext,
|
17
|
-
user: 'dummy',
|
18
|
-
pass: 'dummy')
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'response doc stdout with invalid UTF-8 characters' do
|
22
|
-
let(:test_data_stdout) { 'ffff' } # Base64-decodes to '}\xF7\xDF', an invalid sequence
|
23
|
-
let(:test_data_stderr) { '' }
|
24
|
-
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
25
|
-
|
26
|
-
before do
|
27
|
-
allow(service).to receive(:send_get_output_message).and_return(
|
28
|
-
REXML::Document.new(test_data_xml)
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'does not raise an ArgumentError: invalid byte sequence in UTF-8' do
|
33
|
-
begin
|
34
|
-
expect(
|
35
|
-
service.get_command_output(shell_id, command_id)
|
36
|
-
).not_to raise_error
|
37
|
-
rescue RSpec::Expectations::ExpectationNotMetError => e
|
38
|
-
expect(e.message).not_to include 'ArgumentError'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'does not have an empty stdout' do
|
43
|
-
expect(
|
44
|
-
service.get_command_output(shell_id, command_id)[:data][0][:stdout]
|
45
|
-
).not_to be_empty
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'response doc stdout with valid UTF-8' do
|
50
|
-
let(:test_data_raw) { '✓1234-äöü' }
|
51
|
-
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
52
|
-
let(:test_data_stderr) { '' }
|
53
|
-
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
54
|
-
|
55
|
-
before do
|
56
|
-
allow(service).to receive(:send_get_output_message).and_return(
|
57
|
-
REXML::Document.new(test_data_xml)
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'decodes to match input data' do
|
62
|
-
expect(
|
63
|
-
service.get_command_output(shell_id, command_id)[:data][0][:stdout]
|
64
|
-
).to eq(test_data_raw)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'winrm/winrm_service'
|
3
|
+
require 'rexml/document'
|
4
|
+
require 'erb'
|
5
|
+
require 'base64'
|
6
|
+
|
7
|
+
describe 'issue 184', unit: true do
|
8
|
+
let(:shell_id) { 'shell-123' }
|
9
|
+
let(:command_id) { 123 }
|
10
|
+
let(:test_data_xml_template) do
|
11
|
+
ERB.new(File.read('spec/stubs/responses/get_command_output_response.xml.erb'))
|
12
|
+
end
|
13
|
+
let(:service) do
|
14
|
+
WinRM::WinRMWebService.new(
|
15
|
+
'http://dummy/wsman',
|
16
|
+
:plaintext,
|
17
|
+
user: 'dummy',
|
18
|
+
pass: 'dummy')
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'response doc stdout with invalid UTF-8 characters' do
|
22
|
+
let(:test_data_stdout) { 'ffff' } # Base64-decodes to '}\xF7\xDF', an invalid sequence
|
23
|
+
let(:test_data_stderr) { '' }
|
24
|
+
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
25
|
+
|
26
|
+
before do
|
27
|
+
allow(service).to receive(:send_get_output_message).and_return(
|
28
|
+
REXML::Document.new(test_data_xml)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'does not raise an ArgumentError: invalid byte sequence in UTF-8' do
|
33
|
+
begin
|
34
|
+
expect(
|
35
|
+
service.get_command_output(shell_id, command_id)
|
36
|
+
).not_to raise_error
|
37
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
38
|
+
expect(e.message).not_to include 'ArgumentError'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'does not have an empty stdout' do
|
43
|
+
expect(
|
44
|
+
service.get_command_output(shell_id, command_id)[:data][0][:stdout]
|
45
|
+
).not_to be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'response doc stdout with valid UTF-8' do
|
50
|
+
let(:test_data_raw) { '✓1234-äöü' }
|
51
|
+
let(:test_data_stdout) { Base64.encode64(test_data_raw) }
|
52
|
+
let(:test_data_stderr) { '' }
|
53
|
+
let(:test_data_xml) { test_data_xml_template.result(binding) }
|
54
|
+
|
55
|
+
before do
|
56
|
+
allow(service).to receive(:send_get_output_message).and_return(
|
57
|
+
REXML::Document.new(test_data_xml)
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'decodes to match input data' do
|
62
|
+
expect(
|
63
|
+
service.get_command_output(shell_id, command_id)[:data][0][:stdout]
|
64
|
+
).to eq(test_data_raw)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/issue_59_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
describe 'issue 59', integration: true do
|
3
|
-
before(:all) do
|
4
|
-
@winrm = winrm_connection
|
5
|
-
end
|
6
|
-
|
7
|
-
describe 'long running script without output' do
|
8
|
-
let(:logged_output) { StringIO.new }
|
9
|
-
let(:logger) { Logging.logger(logged_output) }
|
10
|
-
|
11
|
-
it 'should not error' do
|
12
|
-
@winrm.set_timeout(1)
|
13
|
-
@winrm.logger = logger
|
14
|
-
|
15
|
-
out = @winrm.powershell('$ProgressPreference="SilentlyContinue";sleep 3; Write-Host "Hello"')
|
16
|
-
|
17
|
-
expect(out).to have_exit_code 0
|
18
|
-
expect(out).to have_stdout_match(/Hello/)
|
19
|
-
expect(out).to have_no_stderr
|
20
|
-
expect(logged_output.string).to match(/retrying receive request/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
describe 'issue 59', integration: true do
|
3
|
+
before(:all) do
|
4
|
+
@winrm = winrm_connection
|
5
|
+
end
|
6
|
+
|
7
|
+
describe 'long running script without output' do
|
8
|
+
let(:logged_output) { StringIO.new }
|
9
|
+
let(:logger) { Logging.logger(logged_output) }
|
10
|
+
|
11
|
+
it 'should not error' do
|
12
|
+
@winrm.set_timeout(1)
|
13
|
+
@winrm.logger = logger
|
14
|
+
|
15
|
+
out = @winrm.powershell('$ProgressPreference="SilentlyContinue";sleep 3; Write-Host "Hello"')
|
16
|
+
|
17
|
+
expect(out).to have_exit_code 0
|
18
|
+
expect(out).to have_stdout_match(/Hello/)
|
19
|
+
expect(out).to have_no_stderr
|
20
|
+
expect(logged_output.string).to match(/retrying receive request/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/matchers.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'rspec/expectations'
|
3
|
-
|
4
|
-
# rspec matchers
|
5
|
-
module WinRMSpecs
|
6
|
-
def self.stdout(output)
|
7
|
-
output[:data].collect do |i|
|
8
|
-
i[:stdout]
|
9
|
-
end.join('\r\n').gsub(/(\\r\\n)+$/, '')
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.stderr(output)
|
13
|
-
output[:data].collect do |i|
|
14
|
-
i[:stderr]
|
15
|
-
end.join('\r\n').gsub(/(\\r\\n)+$/, '')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec::Matchers.define :have_stdout_match do |expected_stdout|
|
20
|
-
match do |actual_output|
|
21
|
-
!expected_stdout.match(WinRMSpecs.stdout(actual_output)).nil?
|
22
|
-
end
|
23
|
-
failure_message do |actual_output|
|
24
|
-
"expected that '#{WinRMSpecs.stdout(actual_output)}' would match #{expected_stdout}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec::Matchers.define :have_stderr_match do |expected_stderr|
|
29
|
-
match do |actual_output|
|
30
|
-
!expected_stderr.match(WinRMSpecs.stderr(actual_output)).nil?
|
31
|
-
end
|
32
|
-
failure_message do |actual_output|
|
33
|
-
"expected that '#{WinRMSpecs.stderr(actual_output)}' would match #{expected_stderr}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
RSpec::Matchers.define :have_no_stdout do
|
38
|
-
match do |actual_output|
|
39
|
-
stdout = WinRMSpecs.stdout(actual_output)
|
40
|
-
stdout == '\r\n' || stdout == ''
|
41
|
-
end
|
42
|
-
failure_message do |actual_output|
|
43
|
-
"expected that '#{WinRMSpecs.stdout(actual_output)}' would have no stdout"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
RSpec::Matchers.define :have_no_stderr do
|
48
|
-
match do |actual_output|
|
49
|
-
stderr = WinRMSpecs.stderr(actual_output)
|
50
|
-
stderr == '\r\n' || stderr == ''
|
51
|
-
end
|
52
|
-
failure_message do |actual_output|
|
53
|
-
"expected that '#{WinRMSpecs.stderr(actual_output)}' would have no stderr"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
RSpec::Matchers.define :have_exit_code do |expected_exit_code|
|
58
|
-
match do |actual_output|
|
59
|
-
expected_exit_code == actual_output[:exitcode]
|
60
|
-
end
|
61
|
-
failure_message do |actual_output|
|
62
|
-
"expected exit code #{expected_exit_code}, but got #{actual_output[:exitcode]}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
RSpec::Matchers.define :be_a_uid do
|
67
|
-
match do |actual|
|
68
|
-
# WinRM1.1 returns uuid's prefixed with 'uuid:' where as later versions do not
|
69
|
-
actual && actual.to_s.match(/^(uuid:)*\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/)
|
70
|
-
end
|
71
|
-
failure_message do |actual|
|
72
|
-
"expected a uid, but got '#{actual}'"
|
73
|
-
end
|
74
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rspec/expectations'
|
3
|
+
|
4
|
+
# rspec matchers
|
5
|
+
module WinRMSpecs
|
6
|
+
def self.stdout(output)
|
7
|
+
output[:data].collect do |i|
|
8
|
+
i[:stdout]
|
9
|
+
end.join('\r\n').gsub(/(\\r\\n)+$/, '')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.stderr(output)
|
13
|
+
output[:data].collect do |i|
|
14
|
+
i[:stderr]
|
15
|
+
end.join('\r\n').gsub(/(\\r\\n)+$/, '')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Matchers.define :have_stdout_match do |expected_stdout|
|
20
|
+
match do |actual_output|
|
21
|
+
!expected_stdout.match(WinRMSpecs.stdout(actual_output)).nil?
|
22
|
+
end
|
23
|
+
failure_message do |actual_output|
|
24
|
+
"expected that '#{WinRMSpecs.stdout(actual_output)}' would match #{expected_stdout}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec::Matchers.define :have_stderr_match do |expected_stderr|
|
29
|
+
match do |actual_output|
|
30
|
+
!expected_stderr.match(WinRMSpecs.stderr(actual_output)).nil?
|
31
|
+
end
|
32
|
+
failure_message do |actual_output|
|
33
|
+
"expected that '#{WinRMSpecs.stderr(actual_output)}' would match #{expected_stderr}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Matchers.define :have_no_stdout do
|
38
|
+
match do |actual_output|
|
39
|
+
stdout = WinRMSpecs.stdout(actual_output)
|
40
|
+
stdout == '\r\n' || stdout == ''
|
41
|
+
end
|
42
|
+
failure_message do |actual_output|
|
43
|
+
"expected that '#{WinRMSpecs.stdout(actual_output)}' would have no stdout"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
RSpec::Matchers.define :have_no_stderr do
|
48
|
+
match do |actual_output|
|
49
|
+
stderr = WinRMSpecs.stderr(actual_output)
|
50
|
+
stderr == '\r\n' || stderr == ''
|
51
|
+
end
|
52
|
+
failure_message do |actual_output|
|
53
|
+
"expected that '#{WinRMSpecs.stderr(actual_output)}' would have no stderr"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
RSpec::Matchers.define :have_exit_code do |expected_exit_code|
|
58
|
+
match do |actual_output|
|
59
|
+
expected_exit_code == actual_output[:exitcode]
|
60
|
+
end
|
61
|
+
failure_message do |actual_output|
|
62
|
+
"expected exit code #{expected_exit_code}, but got #{actual_output[:exitcode]}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
RSpec::Matchers.define :be_a_uid do
|
67
|
+
match do |actual|
|
68
|
+
# WinRM1.1 returns uuid's prefixed with 'uuid:' where as later versions do not
|
69
|
+
actual && actual.to_s.match(/^(uuid:)*\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/)
|
70
|
+
end
|
71
|
+
failure_message do |actual|
|
72
|
+
"expected a uid, but got '#{actual}'"
|
73
|
+
end
|
74
|
+
end
|
data/spec/output_spec.rb
CHANGED
@@ -1,110 +1,110 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
describe WinRM::Output, unit: true do
|
3
|
-
subject { WinRM::Output.new }
|
4
|
-
|
5
|
-
context 'when there is no output' do
|
6
|
-
describe '#stdout' do
|
7
|
-
it 'is empty' do
|
8
|
-
expect(subject.stdout).to be_empty
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#stderr' do
|
13
|
-
it 'is empty' do
|
14
|
-
expect(subject.stderr).to be_empty
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#output' do
|
19
|
-
it 'is empty' do
|
20
|
-
expect(subject.output).to be_empty
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when there is only one line' do
|
26
|
-
describe '#stdout' do
|
27
|
-
it 'is equal to that line' do
|
28
|
-
subject[:data] << { stdout: 'foo' }
|
29
|
-
expect(subject.stdout).to eq('foo')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#stderr' do
|
34
|
-
it 'is equal to that line' do
|
35
|
-
subject[:data] << { stderr: 'foo' }
|
36
|
-
expect(subject.stderr).to eq('foo')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#output' do
|
41
|
-
it 'is equal to stdout' do
|
42
|
-
subject[:data] << { stdout: 'foo' }
|
43
|
-
expect(subject.output).to eq('foo')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'is equal to stderr' do
|
47
|
-
subject[:data] << { stderr: 'foo' }
|
48
|
-
expect(subject.output).to eq('foo')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when there is one line of each type' do
|
54
|
-
before(:each) do
|
55
|
-
subject[:data] << { stdout: 'foo' }
|
56
|
-
subject[:data] << { stderr: 'bar' }
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#stdout' do
|
60
|
-
it 'is equal to that line' do
|
61
|
-
expect(subject.stdout).to eq('foo')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '#stderr' do
|
66
|
-
it 'is equal to that line' do
|
67
|
-
expect(subject.stderr).to eq('bar')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#output' do
|
72
|
-
it 'is equal to stdout + stderr' do
|
73
|
-
expect(subject.output).to eq('foobar')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when there are multiple lines' do
|
79
|
-
before(:each) do
|
80
|
-
subject[:data] << { stdout: 'I can have a newline\nanywhere, ' }
|
81
|
-
subject[:data] << { stderr: 'I can also have stderr' }
|
82
|
-
subject[:data] << { stdout: 'or stdout', stderr: ' and stderr' }
|
83
|
-
subject[:data] << {}
|
84
|
-
subject[:data] << { stdout: ' or nothing! (above)' }
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#stdout' do
|
88
|
-
it 'is equal to that line' do
|
89
|
-
expect(subject.stdout).to eq(
|
90
|
-
'I can have a newline\nanywhere, or stdout or nothing! (above)')
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#stderr' do
|
95
|
-
it 'is equal to that line' do
|
96
|
-
expect(subject.stderr).to eq('I can also have stderr and stderr')
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#output' do
|
101
|
-
it 'is equal to stdout + stderr' do
|
102
|
-
expect(subject.output).to eq(
|
103
|
-
'I can have a newline\nanywhere, I can also have stderror stdout ' \
|
104
|
-
'and stderr or nothing! (above)')
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
pending 'parse CLIXML errors and convert to Strings and/or Exceptions'
|
110
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
describe WinRM::Output, unit: true do
|
3
|
+
subject { WinRM::Output.new }
|
4
|
+
|
5
|
+
context 'when there is no output' do
|
6
|
+
describe '#stdout' do
|
7
|
+
it 'is empty' do
|
8
|
+
expect(subject.stdout).to be_empty
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#stderr' do
|
13
|
+
it 'is empty' do
|
14
|
+
expect(subject.stderr).to be_empty
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#output' do
|
19
|
+
it 'is empty' do
|
20
|
+
expect(subject.output).to be_empty
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when there is only one line' do
|
26
|
+
describe '#stdout' do
|
27
|
+
it 'is equal to that line' do
|
28
|
+
subject[:data] << { stdout: 'foo' }
|
29
|
+
expect(subject.stdout).to eq('foo')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#stderr' do
|
34
|
+
it 'is equal to that line' do
|
35
|
+
subject[:data] << { stderr: 'foo' }
|
36
|
+
expect(subject.stderr).to eq('foo')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#output' do
|
41
|
+
it 'is equal to stdout' do
|
42
|
+
subject[:data] << { stdout: 'foo' }
|
43
|
+
expect(subject.output).to eq('foo')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'is equal to stderr' do
|
47
|
+
subject[:data] << { stderr: 'foo' }
|
48
|
+
expect(subject.output).to eq('foo')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when there is one line of each type' do
|
54
|
+
before(:each) do
|
55
|
+
subject[:data] << { stdout: 'foo' }
|
56
|
+
subject[:data] << { stderr: 'bar' }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#stdout' do
|
60
|
+
it 'is equal to that line' do
|
61
|
+
expect(subject.stdout).to eq('foo')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#stderr' do
|
66
|
+
it 'is equal to that line' do
|
67
|
+
expect(subject.stderr).to eq('bar')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#output' do
|
72
|
+
it 'is equal to stdout + stderr' do
|
73
|
+
expect(subject.output).to eq('foobar')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when there are multiple lines' do
|
79
|
+
before(:each) do
|
80
|
+
subject[:data] << { stdout: 'I can have a newline\nanywhere, ' }
|
81
|
+
subject[:data] << { stderr: 'I can also have stderr' }
|
82
|
+
subject[:data] << { stdout: 'or stdout', stderr: ' and stderr' }
|
83
|
+
subject[:data] << {}
|
84
|
+
subject[:data] << { stdout: ' or nothing! (above)' }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#stdout' do
|
88
|
+
it 'is equal to that line' do
|
89
|
+
expect(subject.stdout).to eq(
|
90
|
+
'I can have a newline\nanywhere, or stdout or nothing! (above)')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#stderr' do
|
95
|
+
it 'is equal to that line' do
|
96
|
+
expect(subject.stderr).to eq('I can also have stderr and stderr')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#output' do
|
101
|
+
it 'is equal to stdout + stderr' do
|
102
|
+
expect(subject.output).to eq(
|
103
|
+
'I can have a newline\nanywhere, I can also have stderror stdout ' \
|
104
|
+
'and stderr or nothing! (above)')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
pending 'parse CLIXML errors and convert to Strings and/or Exceptions'
|
110
|
+
end
|