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
@@ -1,300 +1,161 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
include Rspec::Bash
|
2
3
|
|
3
4
|
describe 'StubbedEnv' do
|
4
|
-
|
5
|
-
let(:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
51
|
-
overridden_function argument_one argument_two
|
52
|
-
|
53
|
-
echo 'standard error output' 1>&2
|
54
|
-
multiline_script
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'calls the stubbed function' do
|
59
|
-
expect(@overridden_function).to be_called_with_arguments('argument_one', 'argument_two')
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'prints the overridden output' do
|
63
|
-
expect(@stdout).to eql('i was overridden')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'and complex arguments (spaces, etc.)' do
|
68
|
-
before(:each) do
|
69
|
-
@stdout, @stderr, @status = subject.execute_inline(
|
70
|
-
<<-multiline_script
|
71
|
-
#!/usr/bin/env bash
|
72
|
-
function overridden_function {
|
73
|
-
echo 'i was not overridden'
|
74
|
-
}
|
75
|
-
overridden_function "argument one" "argument two"
|
76
|
-
|
77
|
-
echo 'standard error output' 1>&2
|
78
|
-
multiline_script
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'calls the stubbed function' do
|
83
|
-
expect(@overridden_function).to be_called_with_arguments('argument one', 'argument two')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'prints the overridden output' do
|
87
|
-
expect(@stdout).to eql('i was overridden')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
context 'with a stubbed command' do
|
92
|
-
before(:each) do
|
93
|
-
@overridden_command = subject.stub_command('overridden_command')
|
94
|
-
@overridden_function = subject.stub_command('overridden_function')
|
95
|
-
@overridden_command.outputs('i was overridden')
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'and no arguments' do
|
99
|
-
before(:each) do
|
100
|
-
@stdout, @stderr, @status = subject.execute_inline(
|
101
|
-
<<-multiline_script
|
102
|
-
#!/usr/bin/env bash
|
103
|
-
overridden_command
|
104
|
-
multiline_script
|
105
|
-
)
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'calls the stubbed command' do
|
109
|
-
expect(@overridden_command).to be_called
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'prints the overridden output' do
|
113
|
-
expect(@stdout).to eql('i was overridden')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'and simple arguments' do
|
118
|
-
before(:each) do
|
119
|
-
@stdout, @stderr, @status = subject.execute_inline(
|
120
|
-
<<-multiline_script
|
121
|
-
#!/usr/bin/env bash
|
122
|
-
overridden_command argument_one argument_two
|
123
|
-
multiline_script
|
124
|
-
)
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'calls the stubbed command' do
|
128
|
-
expect(@overridden_command).to be_called_with_arguments('argument_one', 'argument_two')
|
129
|
-
end
|
5
|
+
subject { StubbedEnv.new(StubbedEnv::RUBY_STUB) }
|
6
|
+
let(:server_thread) { double(Thread) }
|
7
|
+
let(:server_port) { 4000 }
|
8
|
+
let!(:tcp_server) do
|
9
|
+
tcp_server = double(TCPServer)
|
10
|
+
allow(tcp_server).to receive(:addr)
|
11
|
+
.and_return(['ADDR', server_port])
|
12
|
+
allow(TCPServer).to receive(:new)
|
13
|
+
.with('localhost', 0)
|
14
|
+
.and_return(tcp_server)
|
15
|
+
tcp_server
|
16
|
+
end
|
17
|
+
let!(:log_manager) do
|
18
|
+
log_manager = double(CallLogManager)
|
19
|
+
allow(CallLogManager).to receive(:new)
|
20
|
+
.and_return(log_manager)
|
21
|
+
log_manager
|
22
|
+
end
|
23
|
+
let!(:conf_manager) do
|
24
|
+
conf_manager = double(CallConfigurationManager)
|
25
|
+
allow(CallConfigurationManager).to receive(:new)
|
26
|
+
.and_return(conf_manager)
|
27
|
+
conf_manager
|
28
|
+
end
|
29
|
+
let!(:stub_marshaller) do
|
30
|
+
stub_marshaller = double(RubyStubMarshaller)
|
31
|
+
allow(RubyStubMarshaller).to receive(:new)
|
32
|
+
.and_return(stub_marshaller)
|
33
|
+
stub_marshaller
|
34
|
+
end
|
35
|
+
let!(:stub_server) do
|
36
|
+
stub_server = double(StubServer)
|
37
|
+
allow(stub_server).to receive(:start)
|
38
|
+
.and_return(server_thread)
|
39
|
+
allow(StubServer).to receive(:new)
|
40
|
+
.with(log_manager, conf_manager, stub_marshaller)
|
41
|
+
.and_return(stub_server)
|
42
|
+
stub_server
|
43
|
+
end
|
44
|
+
let!(:stub_wrapper) do
|
45
|
+
stub_wrapper = double(BashWrapper)
|
46
|
+
allow(BashWrapper).to receive(:new)
|
47
|
+
.and_return(stub_wrapper)
|
48
|
+
allow(stub_wrapper).to receive(:add_override)
|
49
|
+
stub_wrapper
|
50
|
+
end
|
130
51
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
52
|
+
context '#initialize' do
|
53
|
+
it 'creates and starts a StubServer' do
|
54
|
+
allow(server_thread).to receive(:kill)
|
135
55
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<<-multiline_script
|
140
|
-
#!/usr/bin/env bash
|
141
|
-
overridden_command "argument one" "argument two"
|
142
|
-
multiline_script
|
143
|
-
)
|
144
|
-
end
|
56
|
+
expect(StubServer).to receive(:new)
|
57
|
+
.with(log_manager, conf_manager, stub_marshaller)
|
58
|
+
.and_return(stub_server)
|
145
59
|
|
146
|
-
|
147
|
-
|
148
|
-
end
|
60
|
+
expect(stub_server).to receive(:start)
|
61
|
+
.with(tcp_server)
|
149
62
|
|
150
|
-
|
151
|
-
expect(@stdout).to eql('i was overridden')
|
152
|
-
end
|
153
|
-
end
|
63
|
+
StubbedEnv.new(StubbedEnv::RUBY_STUB)
|
154
64
|
end
|
155
65
|
end
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
expect(@overridden_function).to be_called
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'prints the overridden output' do
|
179
|
-
expect(@stdout).to eql('i was overridden')
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'prints provided stderr output to standard error' do
|
183
|
-
expect(@stderr).to eql("standard error output\n")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context 'and simple arguments' do
|
188
|
-
before(:each) do
|
189
|
-
@stdout, @stderr, @status = subject.execute_function(
|
190
|
-
'./spec/scripts/function_library.sh',
|
191
|
-
'overridden_function argument_one argument_two'
|
192
|
-
)
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'calls the stubbed function' do
|
196
|
-
expect(@overridden_function).to be_called_with_arguments('argument_one', 'argument_two')
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'prints the overridden output' do
|
200
|
-
expect(@stdout).to eql('i was overridden')
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
context 'and complex arguments (spaces, etc.)' do
|
205
|
-
before(:each) do
|
206
|
-
@stdout, @stderr, @status = subject.execute_function(
|
207
|
-
'./spec/scripts/function_library.sh',
|
208
|
-
'overridden_function "argument one" "argument two"'
|
209
|
-
)
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'calls the stubbed function' do
|
213
|
-
expect(@overridden_function).to be_called_with_arguments('argument one', 'argument two')
|
214
|
-
end
|
215
|
-
|
216
|
-
it 'prints the overridden output' do
|
217
|
-
expect(@stdout).to eql('i was overridden')
|
218
|
-
end
|
219
|
-
end
|
66
|
+
context '#stub_command' do
|
67
|
+
let!(:stub_command) do
|
68
|
+
stub_command = double(StubbedCommand)
|
69
|
+
allow(StubbedCommand).to receive(:new)
|
70
|
+
.and_return(stub_command)
|
71
|
+
stub_command
|
72
|
+
end
|
73
|
+
before do
|
74
|
+
stub_function = double(StubFunction)
|
75
|
+
|
76
|
+
allow(stub_function).to receive(:script)
|
77
|
+
.with('first_command')
|
78
|
+
.and_return('first_command override')
|
79
|
+
allow(stub_function).to receive(:script)
|
80
|
+
.with('second_command')
|
81
|
+
.and_return('second_command override')
|
82
|
+
|
83
|
+
allow(StubFunction).to receive(:new)
|
84
|
+
.and_return(stub_function)
|
220
85
|
end
|
221
|
-
context 'with a stubbed command' do
|
222
|
-
before(:each) do
|
223
|
-
@overridden_function = subject.stub_command('overridden_function')
|
224
|
-
@overridden_command = subject.stub_command('overridden_command')
|
225
|
-
@overridden_command.outputs('i was overridden')
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'and no arguments' do
|
229
|
-
before(:each) do
|
230
|
-
@stdout, @stderr, @status = subject.execute_function(
|
231
|
-
'./spec/scripts/function_library.sh',
|
232
|
-
'overridden_command_function'
|
233
|
-
)
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'calls the stubbed command' do
|
237
|
-
expect(@overridden_command).to be_called
|
238
|
-
end
|
239
|
-
|
240
|
-
it 'prints the overridden output' do
|
241
|
-
expect(@stdout).to eql('i was overridden')
|
242
|
-
end
|
243
|
-
|
244
|
-
it 'prints provided stderr output to standard error' do
|
245
|
-
expect(@stderr).to eql("standard error output\n")
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
context 'and simple arguments' do
|
250
|
-
before(:each) do
|
251
|
-
@stdout, @stderr, @status = subject.execute_function(
|
252
|
-
'./spec/scripts/function_library.sh',
|
253
|
-
'overridden_command_function argument_one argument_two'
|
254
|
-
)
|
255
|
-
end
|
256
|
-
|
257
|
-
it 'calls the stubbed command' do
|
258
|
-
expect(@overridden_command).to be_called_with_arguments('argument_one', 'argument_two')
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'prints the overridden output' do
|
262
|
-
expect(@stdout).to eql('i was overridden')
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context 'and complex arguments (spaces, etc.)' do
|
267
|
-
before(:each) do
|
268
|
-
@stdout, @stderr, @status = subject.execute_function(
|
269
|
-
'./spec/scripts/function_library.sh',
|
270
|
-
'overridden_command_function "argument one" "argument two"'
|
271
|
-
)
|
272
|
-
end
|
273
86
|
|
274
|
-
|
275
|
-
|
276
|
-
|
87
|
+
it 'adds the call conf and log managers to the command' do
|
88
|
+
expect(StubbedCommand).to receive(:new)
|
89
|
+
.with('first_command', log_manager, conf_manager)
|
277
90
|
|
278
|
-
|
279
|
-
|
280
|
-
|
91
|
+
command = subject.stub_command('first_command')
|
92
|
+
expect(command).to equal(stub_command)
|
93
|
+
end
|
94
|
+
it 'adds the function override for the command to the wrapper' do
|
95
|
+
expect(stub_wrapper).to receive(:add_override)
|
96
|
+
.with('first_command override')
|
97
|
+
expect(stub_wrapper).to receive(:add_override)
|
98
|
+
.with('second_command override')
|
99
|
+
|
100
|
+
subject.stub_command('first_command')
|
101
|
+
subject.stub_command('second_command')
|
102
|
+
end
|
103
|
+
disallowed_commands = %w(/usr/bin/env bash readonly function)
|
104
|
+
disallowed_commands.each do |command|
|
105
|
+
it "does not allow #{command}" do
|
106
|
+
expect { subject.stub_command(command) }.to raise_error(
|
107
|
+
"Not able to stub command #{command}. Reserved for use by test wrapper."
|
108
|
+
)
|
281
109
|
end
|
282
110
|
end
|
283
111
|
end
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
expect(
|
112
|
+
context '#execute' do
|
113
|
+
it 'wraps the file to execute and sends it to Open3' do
|
114
|
+
allow(stub_wrapper).to receive(:wrap_script)
|
115
|
+
.with('source file_to_execute')
|
116
|
+
.and_return('wrapped script')
|
117
|
+
expect(Open3).to receive(:capture3)
|
118
|
+
.with({ 'DOG' => 'cat' }, 'wrapped script')
|
119
|
+
|
120
|
+
subject.execute('file_to_execute', 'DOG' => 'cat')
|
290
121
|
end
|
291
122
|
end
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
expect(
|
123
|
+
context('#execute_function') do
|
124
|
+
it 'wraps the file to execute and sends it to Open3' do
|
125
|
+
allow(stub_wrapper).to receive(:wrap_script)
|
126
|
+
.with("source file_to_execute\nfunction_to_execute")
|
127
|
+
.and_return('wrapped script')
|
128
|
+
expect(Open3).to receive(:capture3)
|
129
|
+
.with({ 'DOG' => 'cat' }, 'wrapped script')
|
130
|
+
|
131
|
+
subject.execute_function('file_to_execute', 'function_to_execute', 'DOG' => 'cat')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
context '#execute_inline' do
|
135
|
+
before do
|
136
|
+
tempfile = double(Tempfile)
|
137
|
+
allow(tempfile).to receive(:path)
|
138
|
+
.and_return('file_to_execute')
|
139
|
+
allow(Tempfile).to receive(:new)
|
140
|
+
.with('inline-')
|
141
|
+
.and_return(tempfile)
|
142
|
+
allow(stub_wrapper).to receive(:wrap_script)
|
143
|
+
allow(Open3).to receive(:capture3)
|
144
|
+
end
|
145
|
+
it 'puts the inline script into a file' do
|
146
|
+
expect(File).to receive(:write)
|
147
|
+
.with('file_to_execute', 'inline script to execute')
|
148
|
+
expect(File).to receive(:delete)
|
149
|
+
.with('file_to_execute')
|
150
|
+
subject.execute_inline('inline script to execute', 'DOG' => 'cat')
|
151
|
+
end
|
152
|
+
it 'wraps the file to execute and sends it to Open3' do
|
153
|
+
allow(stub_wrapper).to receive(:wrap_script)
|
154
|
+
.with('source file_to_execute')
|
155
|
+
.and_return('wrapped script')
|
156
|
+
expect(Open3).to receive(:capture3)
|
157
|
+
.with({ 'DOG' => 'cat' }, 'wrapped script')
|
158
|
+
subject.execute_inline('inline script to execute', 'DOG' => 'cat')
|
298
159
|
end
|
299
160
|
end
|
300
161
|
end
|
@@ -122,21 +122,21 @@ describe 'CallConfArgumentListMatcher' do
|
|
122
122
|
it 'returns the longest conf match' do
|
123
123
|
argument_list_from_call = %w(first_argument second_argument third_argument)
|
124
124
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
125
|
-
call_conf_match = subject.get_best_call_conf(
|
125
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
126
126
|
expect(call_conf_match).to eql call_conf_list.at(2)
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'returns the last longest conf match for multiple exact matches' do
|
130
130
|
argument_list_from_call = %w(first_argument second_argument)
|
131
131
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
132
|
-
call_conf_match = subject.get_best_call_conf(
|
132
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
133
133
|
expect(call_conf_match).to eql call_conf_list.at(5)
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'returns the longest conf match for any_arg v. anything matches' do
|
137
137
|
argument_list_from_call = %w(first_argument second_argument third_argument fourth_argument)
|
138
138
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
139
|
-
call_conf_match = subject.get_best_call_conf(
|
139
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
140
140
|
expect(call_conf_match).to eql call_conf_list.at(6)
|
141
141
|
end
|
142
142
|
|
@@ -146,14 +146,14 @@ describe 'CallConfArgumentListMatcher' do
|
|
146
146
|
fourth_argument fifth_argument
|
147
147
|
)
|
148
148
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
149
|
-
call_conf_match = subject.get_best_call_conf(
|
149
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
150
150
|
expect(call_conf_match).to eql call_conf_list.at(8)
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'returns the last anything match for multiple, all anything matches' do
|
154
154
|
argument_list_from_call = %w(first_argument)
|
155
155
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
156
|
-
call_conf_match = subject.get_best_call_conf(
|
156
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
157
157
|
expect(call_conf_match).to eql call_conf_list.at(10)
|
158
158
|
end
|
159
159
|
end
|
@@ -227,7 +227,7 @@ describe 'CallConfArgumentListMatcher' do
|
|
227
227
|
argument_list_from_call =
|
228
228
|
%w(first_argument second_argument third_argument fourth_argument fifth_argument)
|
229
229
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
230
|
-
call_conf_match = subject.get_best_call_conf(
|
230
|
+
call_conf_match = subject.get_best_call_conf(argument_list_from_call)
|
231
231
|
expect(call_conf_match).to be_empty
|
232
232
|
end
|
233
233
|
end
|
@@ -338,21 +338,21 @@ describe 'CallConfArgumentListMatcher' do
|
|
338
338
|
it 'returns the correct confs for a single exact/anything argument match' do
|
339
339
|
argument_list_from_call = %w(first_argument second_argument third_argument)
|
340
340
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
341
|
-
call_conf_match_list = subject.get_call_conf_matches(
|
341
|
+
call_conf_match_list = subject.get_call_conf_matches(argument_list_from_call)
|
342
342
|
expect(call_conf_match_list).to eql call_conf_list.values_at(1, 3, 6)
|
343
343
|
end
|
344
344
|
|
345
345
|
it 'returns the correct confs for multiple exact/anything argument matches' do
|
346
346
|
argument_list_from_call = %w(first_argument second_argument)
|
347
347
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
348
|
-
call_conf_match_list = subject.get_call_conf_matches(
|
348
|
+
call_conf_match_list = subject.get_call_conf_matches(argument_list_from_call)
|
349
349
|
expect(call_conf_match_list).to eql call_conf_list.values_at(0, 2, 4, 6)
|
350
350
|
end
|
351
351
|
|
352
352
|
it 'returns the correct confs for the all argument match' do
|
353
353
|
argument_list_from_call = %w(first_argument)
|
354
354
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
355
|
-
call_conf_match_list = subject.get_call_conf_matches(
|
355
|
+
call_conf_match_list = subject.get_call_conf_matches(argument_list_from_call)
|
356
356
|
expect(call_conf_match_list).to eql call_conf_list.values_at(6)
|
357
357
|
end
|
358
358
|
|
@@ -362,7 +362,7 @@ describe 'CallConfArgumentListMatcher' do
|
|
362
362
|
third_argument fourth_argument fifth_argument
|
363
363
|
)
|
364
364
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
365
|
-
actual_args_match = subject.get_call_conf_matches(
|
365
|
+
actual_args_match = subject.get_call_conf_matches(argument_list_from_call)
|
366
366
|
expect(actual_args_match).to eql call_conf_list.values_at(6, 7, 8)
|
367
367
|
end
|
368
368
|
end
|
@@ -447,21 +447,21 @@ describe 'CallConfArgumentListMatcher' do
|
|
447
447
|
it 'returns the correct confs for a single exact/anything argument match' do
|
448
448
|
argument_list_from_call = %w(first_argument second_argument third_argument)
|
449
449
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
450
|
-
actual_args_match = subject.args_match?(
|
450
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
451
451
|
expect(actual_args_match).to be true
|
452
452
|
end
|
453
453
|
|
454
454
|
it 'returns the correct confs for multiple exact/anything argument matches' do
|
455
455
|
argument_list_from_call = %w(first_argument second_argument)
|
456
456
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
457
|
-
actual_args_match = subject.args_match?(
|
457
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
458
458
|
expect(actual_args_match).to be true
|
459
459
|
end
|
460
460
|
|
461
461
|
it 'returns the correct confs for the all argument match' do
|
462
462
|
argument_list_from_call = %w(first_argument)
|
463
463
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
464
|
-
actual_args_match = subject.args_match?(
|
464
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
465
465
|
expect(actual_args_match).to be true
|
466
466
|
end
|
467
467
|
end
|
@@ -547,21 +547,21 @@ describe 'CallConfArgumentListMatcher' do
|
|
547
547
|
it 'returns the correct confs for a single exact/anything argument match' do
|
548
548
|
argument_list_from_call = %w(first_argument second_argument third_argument)
|
549
549
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
550
|
-
actual_args_match = subject.args_match?(
|
550
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
551
551
|
expect(actual_args_match).to be true
|
552
552
|
end
|
553
553
|
|
554
554
|
it 'returns the correct confs for multiple exact/anything argument matches' do
|
555
555
|
argument_list_from_call = %w(first_argument second_argument)
|
556
556
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
557
|
-
actual_args_match = subject.args_match?(
|
557
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
558
558
|
expect(actual_args_match).to be true
|
559
559
|
end
|
560
560
|
|
561
561
|
it 'returns the correct confs for the all argument match' do
|
562
562
|
argument_list_from_call = %w(first_argument)
|
563
563
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
564
|
-
actual_args_match = subject.args_match?(
|
564
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
565
565
|
expect(actual_args_match).to be false
|
566
566
|
end
|
567
567
|
|
@@ -571,7 +571,7 @@ describe 'CallConfArgumentListMatcher' do
|
|
571
571
|
third_argument fourth_argument fifth_argument
|
572
572
|
)
|
573
573
|
subject = CallConfArgumentListMatcher.new(call_conf_list)
|
574
|
-
actual_args_match = subject.args_match?(
|
574
|
+
actual_args_match = subject.args_match?(argument_list_from_call)
|
575
575
|
expect(actual_args_match).to be true
|
576
576
|
end
|
577
577
|
end
|