rspec-bash 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/Gemfile +1 -0
- data/README.md +23 -0
- data/Rakefile +15 -4
- data/bin/bash_stub.sh +92 -0
- data/bin/bash_wrapper.sh.erb +12 -0
- data/bin/ruby_stub.rb +33 -0
- data/lib/rspec/bash.rb +5 -4
- data/lib/rspec/bash/command.rb +5 -0
- data/lib/rspec/bash/command/call_configuration.rb +76 -0
- data/lib/rspec/bash/command/call_configuration_manager.rb +24 -0
- data/lib/rspec/bash/command/call_log.rb +48 -0
- data/lib/rspec/bash/command/call_log_manager.rb +38 -0
- data/lib/rspec/bash/command/stubbed_command.rb +64 -0
- data/lib/rspec/bash/server.rb +3 -0
- data/lib/rspec/bash/server/bash_stub_marshaller.rb +19 -0
- data/lib/rspec/bash/server/ruby_stub_marshaller.rb +13 -0
- data/lib/rspec/bash/server/stub_server.rb +47 -0
- data/lib/rspec/bash/stubbed_env.rb +75 -54
- data/lib/rspec/bash/util/call_conf_argument_list_matcher.rb +5 -5
- data/lib/rspec/bash/util/call_log_argument_list_matcher.rb +1 -1
- data/lib/rspec/bash/wrapper.rb +4 -0
- data/lib/rspec/bash/wrapper/bash_stub_script.rb +15 -0
- data/lib/rspec/bash/wrapper/bash_wrapper.rb +54 -0
- data/lib/rspec/bash/wrapper/ruby_stub_script.rb +15 -0
- data/lib/rspec/bash/wrapper/stub_function.rb +36 -0
- data/rspec-bash.gemspec +2 -1
- data/spec/classes/command/call_configuration_manager_spec.rb +68 -0
- data/spec/classes/{call_configuration_spec.rb → command/call_configuration_spec.rb} +51 -114
- data/spec/classes/command/call_log_manager_spec.rb +83 -0
- data/spec/classes/{call_log_spec.rb → command/call_log_spec.rb} +23 -82
- data/spec/classes/command/stubbed_command_spec.rb +118 -0
- data/spec/classes/server/bash_stub_marshaller_spec.rb +38 -0
- data/spec/classes/server/ruby_stub_marshaller_spec.rb +31 -0
- data/spec/classes/server/stub_server_spec.rb +121 -0
- data/spec/classes/stubbed_env_spec.rb +141 -280
- data/spec/classes/util/call_conf_argument_list_matcher_spec.rb +17 -17
- data/spec/classes/util/call_log_argument_list_matcher_spec.rb +24 -18
- data/spec/classes/wrapper/bash_wrapper_spec.rb +37 -0
- data/spec/classes/wrapper/ruby_stub_script_spec.rb +204 -0
- data/spec/helper/string_file_io.rb +1 -1
- data/spec/integration/call_log/called_with_args_spec.rb +8 -4
- data/spec/integration/call_log/called_with_no_args_spec.rb +1 -1
- data/spec/integration/call_log/stdin_spec.rb +10 -4
- data/spec/integration/edge_cases_spec.rb +34 -0
- data/spec/integration/matchers/be_called_with_arguments_spec.rb +12 -13
- data/spec/integration/matchers/be_called_with_no_arguments_spec.rb +6 -7
- data/spec/integration/stubbed_command/outputs_spec.rb +111 -91
- data/spec/integration/stubbed_command/returns_exitstatus_spec.rb +46 -37
- data/spec/integration/stubbed_env/execute_with_env_vars_spec.rb +3 -4
- data/spec/integration/stubbed_env/execute_with_path_spec.rb +6 -7
- data/spec/integration/stubbed_env/execute_with_stub_wrapper_spec.rb +4 -12
- data/spec/integration/stubbed_env/override_spec.rb +354 -0
- data/spec/integration/wrapper/bash_stub_script_spec.rb +383 -0
- data/spec/integration/wrapper/bash_wrapper_spec.rb +48 -0
- data/spec/scripts/function_library.sh +9 -1
- data/spec/spec_helper.rb +2 -0
- metadata +65 -21
- data/bin/function_override.sh.erb +0 -7
- data/bin/function_override_wrapper.sh.erb +0 -19
- data/bin/stub.rb.erb +0 -56
- data/lib/rspec/bash/call_configuration.rb +0 -62
- data/lib/rspec/bash/call_log.rb +0 -71
- data/lib/rspec/bash/stubbed_command.rb +0 -88
- data/spec/classes/stub_spec.rb +0 -510
- data/spec/classes/stubbed_command_spec.rb +0 -134
- data/spec/integration/assert_called_spec.rb +0 -0
@@ -23,42 +23,42 @@ describe 'CallLogArgumentListMatcher' do
|
|
23
23
|
|
24
24
|
it 'returns the correct count for a single exact argument match' do
|
25
25
|
argument_list_to_match = %w(first_argument second_argument third_argument)
|
26
|
-
subject = CallLogArgumentListMatcher.new(
|
26
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
27
27
|
actual_match_count = subject.get_call_count(call_log_list)
|
28
28
|
expect(actual_match_count).to be 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'returns the correct count for multiple exact argument matches' do
|
32
32
|
argument_list_to_match = %w(first_argument second_argument)
|
33
|
-
subject = CallLogArgumentListMatcher.new(
|
33
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
34
34
|
actual_match_count = subject.get_call_count(call_log_list)
|
35
35
|
expect(actual_match_count).to be 2
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'returns the correct count for no argument matches' do
|
39
39
|
argument_list_to_match = %w(first_argument)
|
40
|
-
subject = CallLogArgumentListMatcher.new(
|
40
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
41
41
|
actual_match_count = subject.get_call_count(call_log_list)
|
42
42
|
expect(actual_match_count).to be 0
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'returns the correct count for a single "anything" match' do
|
46
46
|
argument_list_to_match = ['first_argument', anything, 'third_argument']
|
47
|
-
subject = CallLogArgumentListMatcher.new(
|
47
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
48
48
|
actual_match_count = subject.get_call_count(call_log_list)
|
49
49
|
expect(actual_match_count).to be 1
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'returns the correct count for multiple "anything" matches' do
|
53
53
|
argument_list_to_match = [anything, 'second_argument']
|
54
|
-
subject = CallLogArgumentListMatcher.new(
|
54
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
55
55
|
actual_match_count = subject.get_call_count(call_log_list)
|
56
56
|
expect(actual_match_count).to be 2
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns the correct count for "anything" matches that are not the exact count' do
|
60
60
|
argument_list_to_match = [anything, anything, anything, anything]
|
61
|
-
subject = CallLogArgumentListMatcher.new(
|
61
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
62
62
|
actual_match_count = subject.get_call_count(call_log_list)
|
63
63
|
expect(actual_match_count).to be 0
|
64
64
|
end
|
@@ -92,42 +92,42 @@ describe 'CallLogArgumentListMatcher' do
|
|
92
92
|
|
93
93
|
it 'returns the correct call log entries for a single exact argument match' do
|
94
94
|
argument_list_to_match = %w(first_argument second_argument third_argument)
|
95
|
-
subject = CallLogArgumentListMatcher.new(
|
95
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
96
96
|
matches = subject.get_call_log_matches(call_log_list)
|
97
97
|
expect(matches).to eql call_log_list.values_at(1)
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'returns the correct call log entries for multiple exact argument matches' do
|
101
101
|
argument_list_to_match = %w(first_argument second_argument)
|
102
|
-
subject = CallLogArgumentListMatcher.new(
|
102
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
103
103
|
matches = subject.get_call_log_matches(call_log_list)
|
104
104
|
expect(matches).to eql call_log_list.values_at(0, 2)
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'returns the correct call log entries for no argument matches' do
|
108
108
|
argument_list_to_match = %w(first_argument)
|
109
|
-
subject = CallLogArgumentListMatcher.new(
|
109
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
110
110
|
matches = subject.get_call_log_matches(call_log_list)
|
111
111
|
expect(matches).to eql []
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'returns the correct call log entries for a single "anything" match' do
|
115
115
|
argument_list_to_match = ['first_argument', anything, 'third_argument']
|
116
|
-
subject = CallLogArgumentListMatcher.new(
|
116
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
117
117
|
matches = subject.get_call_log_matches(call_log_list)
|
118
118
|
expect(matches).to eql call_log_list.values_at(1)
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'returns the correct call log entries for multiple "anything" matches' do
|
122
122
|
argument_list_to_match = [anything, 'second_argument']
|
123
|
-
subject = CallLogArgumentListMatcher.new(
|
123
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
124
124
|
matches = subject.get_call_log_matches(call_log_list)
|
125
125
|
expect(matches).to eql call_log_list.values_at(0, 2)
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'returns the correct call log entries for "anything" matches not matching count' do
|
129
129
|
argument_list_to_match = [anything, anything, anything, anything]
|
130
|
-
subject = CallLogArgumentListMatcher.new(
|
130
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
131
131
|
matches = subject.get_call_log_matches(call_log_list)
|
132
132
|
expect(matches).to eql []
|
133
133
|
end
|
@@ -161,42 +161,42 @@ describe 'CallLogArgumentListMatcher' do
|
|
161
161
|
|
162
162
|
it 'returns true for a single exact argument match' do
|
163
163
|
argument_list_to_match = %w(first_argument second_argument third_argument)
|
164
|
-
subject = CallLogArgumentListMatcher.new(
|
164
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
165
165
|
matches = subject.args_match?(call_log_list)
|
166
166
|
expect(matches).to be true
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'returns true for multiple exact argument matches' do
|
170
170
|
argument_list_to_match = %w(first_argument second_argument)
|
171
|
-
subject = CallLogArgumentListMatcher.new(
|
171
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
172
172
|
matches = subject.args_match?(call_log_list)
|
173
173
|
expect(matches).to be true
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'returns false for no argument matches' do
|
177
177
|
argument_list_to_match = %w(first_argument)
|
178
|
-
subject = CallLogArgumentListMatcher.new(
|
178
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
179
179
|
matches = subject.args_match?(call_log_list)
|
180
180
|
expect(matches).to be false
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'returns true for a single "anything" match' do
|
184
184
|
argument_list_to_match = ['first_argument', anything, 'third_argument']
|
185
|
-
subject = CallLogArgumentListMatcher.new(
|
185
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
186
186
|
matches = subject.args_match?(call_log_list)
|
187
187
|
expect(matches).to be true
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'returns true for multiple "anything" matches' do
|
191
191
|
argument_list_to_match = [anything, 'second_argument']
|
192
|
-
subject = CallLogArgumentListMatcher.new(
|
192
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
193
193
|
matches = subject.args_match?(call_log_list)
|
194
194
|
expect(matches).to be true
|
195
195
|
end
|
196
196
|
|
197
197
|
it 'returns false for "anything" matches that are not the exact count' do
|
198
198
|
argument_list_to_match = [anything, anything, anything, anything]
|
199
|
-
subject = CallLogArgumentListMatcher.new(
|
199
|
+
subject = CallLogArgumentListMatcher.new(argument_list_to_match)
|
200
200
|
matches = subject.args_match?(call_log_list)
|
201
201
|
expect(matches).to be false
|
202
202
|
end
|
@@ -206,6 +206,12 @@ describe 'CallLogArgumentListMatcher' do
|
|
206
206
|
matches = subject.args_match?(call_log_list)
|
207
207
|
expect(matches).to be true
|
208
208
|
end
|
209
|
+
|
210
|
+
it 'returns true for an empty expected argument list' do
|
211
|
+
subject = CallLogArgumentListMatcher.new([])
|
212
|
+
matches = subject.args_match?(call_log_list)
|
213
|
+
expect(matches).to be true
|
214
|
+
end
|
209
215
|
end
|
210
216
|
end
|
211
217
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Rspec::Bash
|
3
|
+
|
4
|
+
describe 'BashWrapper' do
|
5
|
+
let(:server_port) { 4000 }
|
6
|
+
subject { BashWrapper.new(server_port) }
|
7
|
+
|
8
|
+
context '#wrap_script' do
|
9
|
+
let(:script) do
|
10
|
+
'echo hello world'
|
11
|
+
end
|
12
|
+
it 'creates a new script that wraps the passed in one' do
|
13
|
+
wrapped_script = subject.wrap_script(script)
|
14
|
+
expect(wrapped_script).to eql File.join(Dir.tmpdir, "wrapper-#{server_port}.sh")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
context '#cleanup' do
|
18
|
+
it 'cleans up its wrapper and stderr files' do
|
19
|
+
existing_file = double(File)
|
20
|
+
allow(existing_file).to receive(:exist?)
|
21
|
+
.and_return true
|
22
|
+
allow(Pathname).to receive(:new)
|
23
|
+
.with(File.join(Dir.tmpdir, "wrapper-#{server_port}.sh"))
|
24
|
+
.and_return(existing_file)
|
25
|
+
allow(Pathname).to receive(:new)
|
26
|
+
.with(File.join(Dir.tmpdir, "stderr-#{server_port}.tmp"))
|
27
|
+
.and_return(existing_file)
|
28
|
+
|
29
|
+
expect(FileUtils).to receive(:remove_entry_secure)
|
30
|
+
.with(File.join(Dir.tmpdir, "wrapper-#{server_port}.sh"))
|
31
|
+
expect(FileUtils).to receive(:remove_entry_secure)
|
32
|
+
.with(File.join(Dir.tmpdir, "stderr-#{server_port}.tmp"))
|
33
|
+
|
34
|
+
subject.cleanup
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Rspec::Bash
|
3
|
+
|
4
|
+
describe 'RubyStubFunction' do
|
5
|
+
let(:subject_path) { RubyStubScript.path }
|
6
|
+
|
7
|
+
let(:stub_output_string_pathname) { instance_double(Pathname) }
|
8
|
+
let(:stub_output_string_file) { StringIO.new }
|
9
|
+
let(:stub_stderr_file) { StringIO.new }
|
10
|
+
let(:stub_stdout_file) { StringIO.new }
|
11
|
+
let(:stub_exit_code_list) { [] }
|
12
|
+
|
13
|
+
let(:stub_socket) { StringFileIO.new }
|
14
|
+
|
15
|
+
def safe_load_subject
|
16
|
+
load subject_path
|
17
|
+
rescue SystemExit
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
$stderr = stub_stderr_file
|
22
|
+
$stdout = stub_stdout_file
|
23
|
+
allow($stdin).to receive(:tty?).and_return(false)
|
24
|
+
|
25
|
+
allow_any_instance_of(Kernel).to receive(:exit) do |_, exit_code|
|
26
|
+
stub_exit_code_list << exit_code
|
27
|
+
raise SystemExit
|
28
|
+
end
|
29
|
+
|
30
|
+
allow(stub_socket).to receive(:close_write)
|
31
|
+
allow(stub_socket).to receive(:close_read)
|
32
|
+
allow(TCPSocket).to receive(:new).and_return(stub_socket)
|
33
|
+
allow(Pathname).to receive(:new).with('tofile')
|
34
|
+
.and_return(stub_output_string_pathname)
|
35
|
+
allow(stub_output_string_pathname).to receive(:open).with('w')
|
36
|
+
.and_yield(stub_output_string_file)
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with no configuration (logging only)' do
|
40
|
+
let!(:call_log_list) { [] }
|
41
|
+
before do
|
42
|
+
allow(stub_socket).to receive(:read).and_return(Marshal.dump({}))
|
43
|
+
expect(TCPSocket).to receive(:new).exactly(4)
|
44
|
+
.with('localhost', 55_555)
|
45
|
+
.and_return(stub_socket)
|
46
|
+
|
47
|
+
ARGV.replace ['first_command', 55_555]
|
48
|
+
allow($stdin).to receive(:read).and_return('')
|
49
|
+
safe_load_subject
|
50
|
+
call_log_list << Marshal.load(stub_socket.string)
|
51
|
+
|
52
|
+
ARGV.replace ['first_command', 55_555]
|
53
|
+
allow($stdin).to receive(:read).and_return("dog\ncat\n")
|
54
|
+
safe_load_subject
|
55
|
+
call_log_list << Marshal.load(stub_socket.string)
|
56
|
+
|
57
|
+
ARGV.replace ['first_command', 55_555, 'first_argument', 'second_argument']
|
58
|
+
allow($stdin).to receive(:read).and_return('')
|
59
|
+
safe_load_subject
|
60
|
+
call_log_list << Marshal.load(stub_socket.string)
|
61
|
+
|
62
|
+
ARGV.replace ['first_command', 55_555, 'first_argument', 'second_argument']
|
63
|
+
allow($stdin).to receive(:read).and_return("dog\ncat\n")
|
64
|
+
safe_load_subject
|
65
|
+
call_log_list << Marshal.load(stub_socket.string)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'logs the correct command for the first call' do
|
69
|
+
expect(call_log_list[0][:command]).to eql 'first_command'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'logs a blank STDIN for the first call' do
|
73
|
+
expect(call_log_list[0][:stdin]).to eql ''
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'logs no arguments for the first call' do
|
77
|
+
expect(call_log_list[0][:args]).to be_empty
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'logs the correct command for the second call' do
|
81
|
+
expect(call_log_list[1][:command]).to eql 'first_command'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'logs some STDIN for the second call' do
|
85
|
+
expect(call_log_list[1][:stdin]).to eql "dog\ncat\n"
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'logs no arguments for the second call' do
|
89
|
+
expect(call_log_list[1][:args]).to be_empty
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'logs the correct command for the third call' do
|
93
|
+
expect(call_log_list[2][:command]).to eql 'first_command'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'logs a blank STDIN for the third call' do
|
97
|
+
expect(call_log_list[2][:stdin]).to be_empty
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'logs some arguments for the third call' do
|
101
|
+
expect(call_log_list[2][:args]).to eql %w(first_argument second_argument)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'logs the correct command for the fourth call' do
|
105
|
+
expect(call_log_list[3][:command]).to eql 'first_command'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'logs some STDIN for the fourth call' do
|
109
|
+
expect(call_log_list[3][:stdin]).to eql "dog\ncat\n"
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'logs some arguments for the fourth call' do
|
113
|
+
expect(call_log_list[3][:args]).to eql %w(first_argument second_argument)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'exits with appropriate code for first call' do
|
117
|
+
expect(stub_exit_code_list[0]).to eql 0
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'exits with appropriate code for second call' do
|
121
|
+
expect(stub_exit_code_list[1]).to eql 0
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'exits with appropriate code for third call' do
|
125
|
+
expect(stub_exit_code_list[2]).to eql 0
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'exits with appropriate code for fourth call' do
|
129
|
+
expect(stub_exit_code_list[3]).to eql 0
|
130
|
+
end
|
131
|
+
end
|
132
|
+
context 'with some configuration (logging and output)' do
|
133
|
+
before do
|
134
|
+
stdout_configuration = {
|
135
|
+
args: [],
|
136
|
+
outputs: [
|
137
|
+
{
|
138
|
+
target: :stderr,
|
139
|
+
content: "stderr\n"
|
140
|
+
},
|
141
|
+
{
|
142
|
+
target: :stdout,
|
143
|
+
content: "stdout\n"
|
144
|
+
},
|
145
|
+
{
|
146
|
+
target: 'tofile',
|
147
|
+
content: "tofile\n"
|
148
|
+
}
|
149
|
+
],
|
150
|
+
exitcode: 8
|
151
|
+
}
|
152
|
+
allow(stub_socket).to receive(:read).and_return(Marshal.dump(stdout_configuration))
|
153
|
+
allow($stdin).to receive(:read).and_return('')
|
154
|
+
|
155
|
+
ARGV.replace ['first_command', 55_555]
|
156
|
+
safe_load_subject
|
157
|
+
|
158
|
+
ARGV.replace ['first_command', 55_555, 'first_argument', 'second_argument']
|
159
|
+
safe_load_subject
|
160
|
+
|
161
|
+
ARGV.replace ['first_command', 55_555, 'first_argument', 'second_argument', 'third_argument']
|
162
|
+
safe_load_subject
|
163
|
+
|
164
|
+
ARGV.replace [
|
165
|
+
'first_command',
|
166
|
+
55_555,
|
167
|
+
'first_argument',
|
168
|
+
'second_argument',
|
169
|
+
'third_argument',
|
170
|
+
'fourth_argument'
|
171
|
+
]
|
172
|
+
|
173
|
+
safe_load_subject
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'prints the expected output to stderr' do
|
177
|
+
expect(stub_stderr_file.string).to eql "stderr\nstderr\nstderr\nstderr\n"
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'prints the expected output to stdout' do
|
181
|
+
expect(stub_stdout_file.string).to eql "stdout\nstdout\nstdout\nstdout\n"
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'prints the expected output to the string named file' do
|
185
|
+
expect(stub_output_string_file.string).to eql "tofile\ntofile\ntofile\ntofile\n"
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'exits with appropriate code for first call' do
|
189
|
+
expect(stub_exit_code_list[0]).to eql 8
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'exits with appropriate code for second call' do
|
193
|
+
expect(stub_exit_code_list[1]).to eql 8
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'exits with appropriate code for third call' do
|
197
|
+
expect(stub_exit_code_list[2]).to eql 8
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'exits with appropriate code for fourth call' do
|
201
|
+
expect(stub_exit_code_list[3]).to eql 8
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
include Rspec::Bash
|
2
3
|
|
3
4
|
describe 'CallLog' do
|
4
|
-
include Rspec::Bash
|
5
5
|
let(:stubbed_env) { create_stubbed_env }
|
6
6
|
let!(:first_command) { stubbed_env.stub_command('first_command') }
|
7
7
|
|
@@ -10,7 +10,7 @@ describe 'CallLog' do
|
|
10
10
|
before(:each) do
|
11
11
|
stubbed_env.execute_inline(
|
12
12
|
<<-multiline_script
|
13
|
-
first_command first_argument
|
13
|
+
first_command first_argument '\nsecond_argument\n'
|
14
14
|
first_command first_argument second_argument third_argument
|
15
15
|
multiline_script
|
16
16
|
)
|
@@ -25,7 +25,7 @@ describe 'CallLog' do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'matches for exact matches' do
|
28
|
-
expect(first_command).to be_called_with_arguments('first_argument',
|
28
|
+
expect(first_command).to be_called_with_arguments('first_argument', "\nsecond_argument\n")
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'matches for anything matches' do
|
@@ -44,6 +44,7 @@ describe 'CallLog' do
|
|
44
44
|
expect(first_command).to be_called_with_arguments(/f..st_argument/, /se..nd_argument/)
|
45
45
|
end
|
46
46
|
|
47
|
+
# rubocop:disable TrailingWhitespace
|
47
48
|
it 'displays the diff between what was called and what was expected' do
|
48
49
|
begin
|
49
50
|
expect(first_command).to be_called_with_arguments('not_first_argument', 'second_argument')
|
@@ -55,12 +56,15 @@ Expected Calls:
|
|
55
56
|
first_command not_first_argument second_argument
|
56
57
|
|
57
58
|
Actual Calls:
|
58
|
-
first_command first_argument
|
59
|
+
first_command first_argument
|
60
|
+
second_argument
|
61
|
+
|
59
62
|
first_command first_argument second_argument third_argument
|
60
63
|
multiline_string
|
61
64
|
expect(rex.message).to eql expected_error_string
|
62
65
|
end
|
63
66
|
end
|
67
|
+
# rubocop:enable TrailingWhitespace
|
64
68
|
it 'displays the diff between what was called and what was not expected' do
|
65
69
|
begin
|
66
70
|
expect(first_command).to_not be_called_with_arguments('first_argument', 'second_argument')
|