|
252 | 252 | end
|
253 | 253 | end
|
254 | 254 |
|
255 |
| - context "given two one-dimensional arrays where the actual has extra elements" do |
| 255 | + context "given two one-dimensional arrays where the actual has elements added to the end" do |
256 | 256 | it "returns a message along with the diff" do
|
257 | 257 | actual_output = described_class.call(
|
258 | 258 | expected: ["bread"],
|
|
275 | 275 | end
|
276 | 276 | end
|
277 | 277 |
|
278 |
| - context "given two one-dimensional arrays where the actual has missing elements" do |
| 278 | + context "given two one-dimensional arrays where the actual has elements missing from the end" do |
279 | 279 | it "returns a message along with the diff" do
|
280 | 280 | actual_output = described_class.call(
|
281 | 281 | expected: ["bread", "eggs", "milk"],
|
|
298 | 298 | end
|
299 | 299 | end
|
300 | 300 |
|
| 301 | + context "given two one-dimensional arrays where the actual has elements added to the beginning" do |
| 302 | + it "returns a message along with the diff" do |
| 303 | + actual_output = described_class.call( |
| 304 | + expected: ["milk"], |
| 305 | + actual: ["bread", "eggs", "milk"] |
| 306 | + ) |
| 307 | + |
| 308 | + expected_output = <<~STR |
| 309 | + Differing arrays. |
| 310 | +
|
| 311 | + Expected: ["milk"] |
| 312 | + Actual: ["bread", "eggs", "milk"] |
| 313 | +
|
| 314 | + Details: |
| 315 | +
|
| 316 | + - *[? -> 0]: Actual has extra element "bread". |
| 317 | + - *[? -> 1]: Actual has extra element "eggs". |
| 318 | + STR |
| 319 | + |
| 320 | + expect(actual_output).to eq(expected_output) |
| 321 | + end |
| 322 | + end |
| 323 | + |
| 324 | + context "given two one-dimensional arrays where the actual has elements removed from the beginning" do |
| 325 | + it "returns a message along with the diff" do |
| 326 | + actual_output = described_class.call( |
| 327 | + expected: ["bread", "eggs", "milk"], |
| 328 | + actual: ["milk"] |
| 329 | + ) |
| 330 | + |
| 331 | + expected_output = <<~STR |
| 332 | + Differing arrays. |
| 333 | +
|
| 334 | + Expected: ["bread", "eggs", "milk"] |
| 335 | + Actual: ["milk"] |
| 336 | +
|
| 337 | + Details: |
| 338 | +
|
| 339 | + - *[0 -> ?]: Actual is missing element "bread". |
| 340 | + - *[1 -> ?]: Actual is missing element "eggs". |
| 341 | + STR |
| 342 | + |
| 343 | + expect(actual_output).to eq(expected_output) |
| 344 | + end |
| 345 | + end |
| 346 | + |
301 | 347 | context "given the same hash" do
|
302 | 348 | it "returns an empty string" do
|
303 | 349 | output = described_class.call(
|
|
0 commit comments