|
156 | 156 | context 'with standalone key' do |
157 | 157 | context 'when not existing' do |
158 | 158 | it 'should append standalone key' do |
| 159 | + described_object = described_class.allocate |
| 160 | + cmdline = ['--foo', '--bar=baz'] |
| 161 | + test_cmdline = ['--baz'] |
| 162 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 163 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 164 | + expect(cmdline).to include('--foo') |
| 165 | + expect(cmdline).to include('--bar=baz') |
| 166 | + expect(cmdline).to include('--baz') |
| 167 | + expect(cmdline.size).to eq(3) |
159 | 168 | end |
160 | 169 | end |
161 | 170 |
|
162 | 171 | context 'when existing as standalone key' do |
163 | 172 | it 'should keep standalone key' do |
| 173 | + described_object = described_class.allocate |
| 174 | + cmdline = ['--foo', '--bar=baz'] |
| 175 | + test_cmdline = ['--foo'] |
| 176 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 177 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 178 | + expect(cmdline).to include('--foo') |
| 179 | + expect(cmdline).to include('--bar=baz') |
| 180 | + expect(cmdline.size).to eq(2) |
164 | 181 | end |
165 | 182 | end |
166 | 183 |
|
167 | 184 | context 'when existing as key=val' do |
168 | 185 | it 'should replace key=val with standalone key' do |
| 186 | + described_object = described_class.allocate |
| 187 | + cmdline = ['--foo', '--bar=baz'] |
| 188 | + test_cmdline = ['--bar'] |
| 189 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 190 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 191 | + expect(cmdline).to include('--foo') |
| 192 | + expect(cmdline).to include('--bar') |
| 193 | + expect(cmdline.size).to eq(2) |
169 | 194 | end |
170 | 195 | end |
171 | 196 | end |
172 | 197 |
|
173 | 198 | context 'with key=val' do |
174 | 199 | context 'when not existing' do |
175 | 200 | it 'should append key=val' do |
| 201 | + described_object = described_class.allocate |
| 202 | + cmdline = ['--foo', '--bar=baz'] |
| 203 | + test_cmdline = ['--baz=buzz'] |
| 204 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 205 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 206 | + expect(cmdline).to include('--foo') |
| 207 | + expect(cmdline).to include('--bar=baz') |
| 208 | + expect(cmdline).to include('--baz=buzz') |
| 209 | + expect(cmdline.size).to eq(3) |
176 | 210 | end |
177 | 211 | end |
178 | 212 |
|
179 | 213 | context 'when existing as standalone key' do |
180 | 214 | it 'should replace standalone key with key=val' do |
| 215 | + described_object = described_class.allocate |
| 216 | + cmdline = ['--foo', '--bar=baz'] |
| 217 | + test_cmdline = ['--foo=buzz'] |
| 218 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 219 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 220 | + expect(cmdline).to include('--foo=buzz') |
| 221 | + expect(cmdline).to include('--bar=baz') |
| 222 | + expect(cmdline.size).to eq(2) |
181 | 223 | end |
182 | 224 | end |
183 | 225 |
|
184 | 226 | context 'when existing as key=val' do |
185 | 227 | it 'should replace key=val with new key=val' do |
| 228 | + described_object = described_class.allocate |
| 229 | + cmdline = ['--foo', '--bar=baz'] |
| 230 | + test_cmdline = ['--bar=buzz'] |
| 231 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 232 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 233 | + expect(cmdline).to include('--foo') |
| 234 | + expect(cmdline).to include('--bar=buzz') |
| 235 | + expect(cmdline.size).to eq(2) |
186 | 236 | end |
187 | 237 | end |
188 | 238 | end |
189 | 239 |
|
190 | 240 | context 'with invalid format' do |
191 | 241 | it 'should raise ArgumentError' do |
| 242 | + described_object = described_class.allocate |
| 243 | + cmdline = ['--foo', '--bar=baz'] |
| 244 | + test_cmdline = ['asdlkfj'] |
| 245 | + described_object.instance_variable_set('@options', command_line: test_cmdline) |
| 246 | + expect do |
| 247 | + described_object.send(:override_and_append_commandline_with_user_supplied_arguments, cmdline) |
| 248 | + end.to raise_error(ArgumentError) |
192 | 249 | end |
193 | 250 | end |
194 | 251 | end |
|
0 commit comments