Skip to content

Commit 8f54d34

Browse files
authored
Merge pull request cstack#15 from whtsky/eq-to-match_array
repace `eq` with `match_array` in spec
2 parents b7cbae4 + ee020df commit 8f54d34

9 files changed

Lines changed: 36 additions & 36 deletions

File tree

_parts/part10.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ Here's a test case for the new printing functionality!
409409
+ script << ".exit"
410410
+ result = run_script(script)
411411
+
412-
+ expect(result[14...(result.length)]).to eq([
412+
+ expect(result[14...(result.length)]).to match_array([
413413
+ "db > Tree:",
414414
+ "- internal (size 1)",
415415
+ " - leaf (size 7)",

_parts/part11.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ And that reveals that our 1400-row test outputs this error:
102102
script << ".exit"
103103
result = run_script(script)
104104
- expect(result[-2]).to eq('db > Error: Table full.')
105-
+ expect(result.last(2)).to eq([
105+
+ expect(result.last(2)).to match_array([
106106
+ "db > Executed.",
107107
+ "db > Need to implement updating parent after split",
108108
+ ])

_parts/part12.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We now support constructing a multi-level btree, but we've broken `select` state
1515
+ script << ".exit"
1616
+ result = run_script(script)
1717
+
18-
+ expect(result[15...result.length]).to eq([
18+
+ expect(result[15...result.length]).to match_array([
1919
+ "db > (1, user1, person1@example.com)",
2020
+ "(2, user2, person2@example.com)",
2121
+ "(3, user3, person3@example.com)",

_parts/part13.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Speaking of tests, our large-dataset test gets past our old stub and gets to our
182182
```diff
183183
@@ -65,7 +65,7 @@ describe 'database' do
184184
result = run_script(script)
185-
expect(result.last(2)).to eq([
185+
expect(result.last(2)).to match_array([
186186
"db > Executed.",
187187
- "db > Need to implement updating parent after split",
188188
+ "db > Need to implement splitting internal node",

_parts/part4.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe 'database' do
3232
"select",
3333
".exit",
3434
])
35-
expect(result).to eq([
35+
expect(result).to match_array([
3636
"db > Executed.",
3737
"db > (1, user1, person1@example.com)",
3838
"Executed.",
@@ -85,7 +85,7 @@ it 'allows inserting strings that are the maximum length' do
8585
".exit",
8686
]
8787
result = run_script(script)
88-
expect(result).to eq([
88+
expect(result).to match_array([
8989
"db > Executed.",
9090
"db > (1, #{long_username}, #{long_email})",
9191
"Executed.",
@@ -151,7 +151,7 @@ it 'prints error message if strings are too long' do
151151
".exit",
152152
]
153153
result = run_script(script)
154-
expect(result).to eq([
154+
expect(result).to match_array([
155155
"db > String is too long.",
156156
"db > Executed.",
157157
"db > ",
@@ -263,7 +263,7 @@ it 'prints an error message if id is negative' do
263263
".exit",
264264
]
265265
result = run_script(script)
266-
expect(result).to eq([
266+
expect(result).to match_array([
267267
"db > ID must be positive.",
268268
"db > Executed.",
269269
"db > ",
@@ -410,7 +410,7 @@ And we added tests:
410410
+ "select",
411411
+ ".exit",
412412
+ ])
413-
+ expect(result).to eq([
413+
+ expect(result).to match_array([
414414
+ "db > Executed.",
415415
+ "db > (1, user1, person1@example.com)",
416416
+ "Executed.",
@@ -436,7 +436,7 @@ And we added tests:
436436
+ ".exit",
437437
+ ]
438438
+ result = run_script(script)
439-
+ expect(result).to eq([
439+
+ expect(result).to match_array([
440440
+ "db > Executed.",
441441
+ "db > (1, #{long_username}, #{long_email})",
442442
+ "Executed.",
@@ -453,7 +453,7 @@ And we added tests:
453453
+ ".exit",
454454
+ ]
455455
+ result = run_script(script)
456-
+ expect(result).to eq([
456+
+ expect(result).to match_array([
457457
+ "db > String is too long.",
458458
+ "db > Executed.",
459459
+ "db > ",
@@ -467,7 +467,7 @@ And we added tests:
467467
+ ".exit",
468468
+ ]
469469
+ result = run_script(script)
470-
+ expect(result).to eq([
470+
+ expect(result).to match_array([
471471
+ "db > ID must be positive.",
472472
+ "db > Executed.",
473473
+ "db > ",

_parts/part5.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ it 'keeps data after closing connection' do
1313
"insert 1 user1 person1@example.com",
1414
".exit",
1515
])
16-
expect(result1).to eq([
16+
expect(result1).to match_array([
1717
"db > Executed.",
1818
"db > ",
1919
])
2020
result2 = run_script([
2121
"select",
2222
".exit",
2323
])
24-
expect(result2).to eq([
24+
expect(result2).to match_array([
2525
"db > (1, user1, person1@example.com)",
2626
"Executed.",
2727
"db > ",
@@ -533,7 +533,7 @@ index 21561ce..bc0180a 100644
533533
+ "insert 1 user1 person1@example.com",
534534
+ ".exit",
535535
+ ])
536-
+ expect(result1).to eq([
536+
+ expect(result1).to match_array([
537537
+ "db > Executed.",
538538
+ "db > ",
539539
+ ])
@@ -542,7 +542,7 @@ index 21561ce..bc0180a 100644
542542
+ "select",
543543
+ ".exit",
544544
+ ])
545-
+ expect(result2).to eq([
545+
+ expect(result2).to match_array([
546546
+ "db > (1, user1, person1@example.com)",
547547
+ "Executed.",
548548
+ "db > ",
@@ -577,7 +577,7 @@ And the diff to our tests:
577577
+ "insert 1 user1 person1@example.com",
578578
+ ".exit",
579579
+ ])
580-
+ expect(result1).to eq([
580+
+ expect(result1).to match_array([
581581
+ "db > Executed.",
582582
+ "db > ",
583583
+ ])
@@ -586,7 +586,7 @@ And the diff to our tests:
586586
+ "select",
587587
+ ".exit",
588588
+ ])
589-
+ expect(result2).to eq([
589+
+ expect(result2).to match_array([
590590
+ "db > (1, user1, person1@example.com)",
591591
+ "Executed.",
592592
+ "db > ",

_parts/part8.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ I'm also adding a test so we get alerted when those constants change:
417417
+ ]
418418
+ result = run_script(script)
419419
+
420-
+ expect(result).to eq([
420+
+ expect(result).to match_array([
421421
+ "db > Constants:",
422422
+ "ROW_SIZE: 293",
423423
+ "COMMON_NODE_HEADER_SIZE: 6",
@@ -477,7 +477,7 @@ And a test
477477
+ script << ".exit"
478478
+ result = run_script(script)
479479
+
480-
+ expect(result).to eq([
480+
+ expect(result).to match_array([
481481
+ "db > Executed.",
482482
+ "db > Executed.",
483483
+ "db > Executed.",
@@ -829,7 +829,7 @@ And the specs:
829829
+ script << ".exit"
830830
+ result = run_script(script)
831831
+
832-
+ expect(result).to eq([
832+
+ expect(result).to match_array([
833833
+ "db > Executed.",
834834
+ "db > Executed.",
835835
+ "db > Executed.",
@@ -849,7 +849,7 @@ And the specs:
849849
+ ]
850850
+ result = run_script(script)
851851
+
852-
+ expect(result).to eq([
852+
+ expect(result).to match_array([
853853
+ "db > Constants:",
854854
+ "ROW_SIZE: 293",
855855
+ "COMMON_NODE_HEADER_SIZE: 6",

_parts/part9.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ And we can add a new test for duplicate keys:
184184
+ ".exit",
185185
+ ]
186186
+ result = run_script(script)
187-
+ expect(result).to eq([
187+
+ expect(result).to match_array([
188188
+ "db > Executed.",
189189
+ "db > Error: Duplicate key.",
190190
+ "db > (1, user1, person1@example.com)",

spec/main_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_script(commands)
2828
"select",
2929
".exit",
3030
])
31-
expect(result).to eq([
31+
expect(result).to match_array([
3232
"db > Executed.",
3333
"db > (1, user1, person1@example.com)",
3434
"Executed.",
@@ -41,7 +41,7 @@ def run_script(commands)
4141
"insert 1 user1 person1@example.com",
4242
".exit",
4343
])
44-
expect(result1).to eq([
44+
expect(result1).to match_array([
4545
"db > Executed.",
4646
"db > ",
4747
])
@@ -50,7 +50,7 @@ def run_script(commands)
5050
"select",
5151
".exit",
5252
])
53-
expect(result2).to eq([
53+
expect(result2).to match_array([
5454
"db > (1, user1, person1@example.com)",
5555
"Executed.",
5656
"db > ",
@@ -63,7 +63,7 @@ def run_script(commands)
6363
end
6464
script << ".exit"
6565
result = run_script(script)
66-
expect(result.last(2)).to eq([
66+
expect(result.last(2)).to match_array([
6767
"db > Executed.",
6868
"db > Need to implement splitting internal node",
6969
])
@@ -78,7 +78,7 @@ def run_script(commands)
7878
".exit",
7979
]
8080
result = run_script(script)
81-
expect(result).to eq([
81+
expect(result).to match_array([
8282
"db > Executed.",
8383
"db > (1, #{long_username}, #{long_email})",
8484
"Executed.",
@@ -95,7 +95,7 @@ def run_script(commands)
9595
".exit",
9696
]
9797
result = run_script(script)
98-
expect(result).to eq([
98+
expect(result).to match_array([
9999
"db > String is too long.",
100100
"db > Executed.",
101101
"db > ",
@@ -109,7 +109,7 @@ def run_script(commands)
109109
".exit",
110110
]
111111
result = run_script(script)
112-
expect(result).to eq([
112+
expect(result).to match_array([
113113
"db > ID must be positive.",
114114
"db > Executed.",
115115
"db > ",
@@ -124,7 +124,7 @@ def run_script(commands)
124124
".exit",
125125
]
126126
result = run_script(script)
127-
expect(result).to eq([
127+
expect(result).to match_array([
128128
"db > Executed.",
129129
"db > Error: Duplicate key.",
130130
"db > (1, user1, person1@example.com)",
@@ -141,7 +141,7 @@ def run_script(commands)
141141
script << ".exit"
142142
result = run_script(script)
143143

144-
expect(result).to eq([
144+
expect(result).to match_array([
145145
"db > Executed.",
146146
"db > Executed.",
147147
"db > Executed.",
@@ -163,7 +163,7 @@ def run_script(commands)
163163
script << ".exit"
164164
result = run_script(script)
165165

166-
expect(result[14...(result.length)]).to eq([
166+
expect(result[14...(result.length)]).to match_array([
167167
"db > Tree:",
168168
"- internal (size 1)",
169169
" - leaf (size 7)",
@@ -225,7 +225,7 @@ def run_script(commands)
225225
]
226226
result = run_script(script)
227227

228-
expect(result[30...(result.length)]).to eq([
228+
expect(result[30...(result.length)]).to match_array([
229229
"db > Tree:",
230230
"- internal (size 3)",
231231
" - leaf (size 7)",
@@ -276,7 +276,7 @@ def run_script(commands)
276276
]
277277
result = run_script(script)
278278

279-
expect(result).to eq([
279+
expect(result).to match_array([
280280
"db > Constants:",
281281
"ROW_SIZE: 293",
282282
"COMMON_NODE_HEADER_SIZE: 6",
@@ -296,7 +296,7 @@ def run_script(commands)
296296
script << "select"
297297
script << ".exit"
298298
result = run_script(script)
299-
expect(result[15...result.length]).to eq([
299+
expect(result[15...result.length]).to match_array([
300300
"db > (1, user1, person1@example.com)",
301301
"(2, user2, person2@example.com)",
302302
"(3, user3, person3@example.com)",

0 commit comments

Comments
 (0)