specdiff 0.3.0.pre.rc1 → 0.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/CHANGELOG.md +15 -1
- data/README.md +1 -2
- data/lib/specdiff/compare.rb +2 -2
- data/lib/specdiff/diff.rb +10 -7
- data/lib/specdiff/differ/{hashdiff.rb → hash.rb} +48 -34
- data/lib/specdiff/differ.rb +1 -1
- data/lib/specdiff/hashprint.rb +47 -27
- data/lib/specdiff/inspect.rb +94 -1
- data/lib/specdiff/rspec.rb +6 -13
- data/lib/specdiff/version.rb +1 -1
- data/lib/specdiff/webmock.rb +4 -2
- data/specdiff.gemspec +6 -7
- metadata +4 -20
- data/.rspec +0 -3
- data/.rubocop.yml +0 -203
- data/.tool-versions +0 -1
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -76
- data/Rakefile +0 -12
- data/assets/webmock_json_with_specdiff.png +0 -0
- data/assets/webmock_text_with_specdiff.png +0 -0
- data/examples/rspec/.rspec +0 -2
- data/examples/rspec/Gemfile +0 -10
- data/examples/rspec/Gemfile.lock +0 -52
- data/examples/rspec/spec/example_spec.rb +0 -678
- data/examples/rspec/spec/spec_helper.rb +0 -68
- data/examples/webmock/Gemfile +0 -6
- data/examples/webmock/Gemfile.lock +0 -50
- data/examples/webmock/json.rb +0 -37
- data/examples/webmock/text.rb +0 -39
@@ -1,678 +0,0 @@
|
|
1
|
-
require "date"
|
2
|
-
|
3
|
-
RSpec.describe "" do
|
4
|
-
it "has a passing spec" do
|
5
|
-
expect(1).to eq(1)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "eq" do
|
9
|
-
it "numbers" do
|
10
|
-
expect(463).to eq(3459)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "booleans" do
|
14
|
-
expect(true).to eq(false)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "strings" do
|
18
|
-
it "short strings" do
|
19
|
-
expect("baglro").to eq("vinefde")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "single line differing encodings" do
|
23
|
-
s1 = "hello".encode("UTF-16")
|
24
|
-
s2 = "hello".encode("UTF-8")
|
25
|
-
|
26
|
-
expect(s1).to eq(s2)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "short multiline strings" do
|
30
|
-
s1 = "a\nb\nc"
|
31
|
-
s2 = "x\ny\nc\n"
|
32
|
-
|
33
|
-
expect(s1).to eq(s2)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "long multiline strings" do
|
37
|
-
s1 = <<~MSG
|
38
|
-
this is gtex
|
39
|
-
|
40
|
-
<hml> haha </hml>
|
41
|
-
|
42
|
-
pweoekeoekwpef
|
43
|
-
|
44
|
-
cam shaft motorway
|
45
|
-
ca shaft morord day
|
46
|
-
|
47
|
-
video games
|
48
|
-
MSG
|
49
|
-
|
50
|
-
s2 = <<~MSG
|
51
|
-
You can have as many gain nodes as you want (this is how you could achieve mixing bus-like setups, for example), so that's not the problem. Your problem is the following:
|
52
|
-
|
53
|
-
Remember that the second parameter to linearRampToValueAtTime() is time in the same time coordinate system as your context.currentTime.
|
54
|
-
|
55
|
-
And your context.currentTime is always moving forward in real time, so all your ramps, curves, etc. should be calculated relative to it.
|
56
|
-
|
57
|
-
If you want something to happen 4 seconds from now, you'd pass context.currentTime + 4 to the Web Audio API function.
|
58
|
-
|
59
|
-
So, change all your calls linearRampToValueAtTime() in your code, so that they look like:
|
60
|
-
|
61
|
-
MSG
|
62
|
-
|
63
|
-
expect(s1).to eq(s2)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "long strings with no newlines" do
|
67
|
-
s1 = <<~MSG.delete("\n")
|
68
|
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
69
|
-
MSG
|
70
|
-
|
71
|
-
s2 = <<~MSG.delete("\n")
|
72
|
-
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
|
73
|
-
MSG
|
74
|
-
|
75
|
-
expect(s1).to eq(s2)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "long strings, no newlines and subtle difference" do
|
79
|
-
s1 = <<~MSG.chomp
|
80
|
-
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.
|
81
|
-
MSG
|
82
|
-
|
83
|
-
s2 = <<~MSG.chomp
|
84
|
-
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our belng able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.
|
85
|
-
MSG
|
86
|
-
|
87
|
-
expect(s1).to eq(s2)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "multi line multi hunk" do
|
91
|
-
s1 = <<~MSG.chomp
|
92
|
-
a
|
93
|
-
|
94
|
-
aa
|
95
|
-
aaa
|
96
|
-
aaa
|
97
|
-
a
|
98
|
-
|
99
|
-
a
|
100
|
-
a
|
101
|
-
a
|
102
|
-
a
|
103
|
-
a
|
104
|
-
a
|
105
|
-
a
|
106
|
-
a
|
107
|
-
|
108
|
-
aghf
|
109
|
-
|
110
|
-
be
|
111
|
-
bebeb
|
112
|
-
be
|
113
|
-
eeb
|
114
|
-
bebe
|
115
|
-
d
|
116
|
-
|
117
|
-
segesrgawf
|
118
|
-
segesrgawf
|
119
|
-
segesrgawf
|
120
|
-
segesrgawf
|
121
|
-
segesrgawf
|
122
|
-
segesrgawf
|
123
|
-
segesrgawf
|
124
|
-
|
125
|
-
a
|
126
|
-
aaa
|
127
|
-
ddd
|
128
|
-
s
|
129
|
-
MSG
|
130
|
-
s2 = <<~MSG.chomp
|
131
|
-
a
|
132
|
-
|
133
|
-
aa
|
134
|
-
aba
|
135
|
-
aaa
|
136
|
-
a
|
137
|
-
|
138
|
-
a
|
139
|
-
a
|
140
|
-
a
|
141
|
-
b
|
142
|
-
a
|
143
|
-
a
|
144
|
-
a
|
145
|
-
a
|
146
|
-
|
147
|
-
aghf
|
148
|
-
|
149
|
-
be
|
150
|
-
bebeb
|
151
|
-
be
|
152
|
-
eeb
|
153
|
-
bebe
|
154
|
-
d
|
155
|
-
|
156
|
-
segesrgawf
|
157
|
-
segesrgawf
|
158
|
-
segesrgawf
|
159
|
-
segesrgawf
|
160
|
-
segesrgawf
|
161
|
-
segesrgawf
|
162
|
-
|
163
|
-
a
|
164
|
-
aaa
|
165
|
-
ddd
|
166
|
-
s
|
167
|
-
MSG
|
168
|
-
|
169
|
-
expect(s1).to eq(s2)
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "multi matcher" do
|
173
|
-
it ".and" do
|
174
|
-
expect("s\nn\nl\n").to eq("k\ntl")
|
175
|
-
.and(eq("s\ne\nl"))
|
176
|
-
end
|
177
|
-
|
178
|
-
it ".or" do
|
179
|
-
expect("s\nn\nl\n").to eq("k\ntl")
|
180
|
-
.or(eq("s\ne\nl"))
|
181
|
-
end
|
182
|
-
|
183
|
-
it ".all" do
|
184
|
-
expect([
|
185
|
-
"s\nn\nl",
|
186
|
-
"v\nd\nl",
|
187
|
-
]).to all(eq("j\no\nh"))
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe "hashes" do
|
193
|
-
it "1 key, value difference" do
|
194
|
-
expect({alpha: "wares"}).to eq({alpha: "waldo"})
|
195
|
-
end
|
196
|
-
it "1 key, key difference" do
|
197
|
-
expect({beta: "wares"}).to eq({alpha: "wares"})
|
198
|
-
end
|
199
|
-
|
200
|
-
it "5 keys" do
|
201
|
-
expect({
|
202
|
-
a: :b,
|
203
|
-
c: "d",
|
204
|
-
ee: "k",
|
205
|
-
b: 22,
|
206
|
-
"k" => :then,
|
207
|
-
}).to eq({
|
208
|
-
a: "b",
|
209
|
-
c: "de",
|
210
|
-
ea: "k",
|
211
|
-
l: 23,
|
212
|
-
"m" => :ok,
|
213
|
-
})
|
214
|
-
end
|
215
|
-
|
216
|
-
it "more keys than lcs context, mostly nested" do
|
217
|
-
expect({
|
218
|
-
"slasher" => [
|
219
|
-
{
|
220
|
-
tigress: 4,
|
221
|
-
coffee: Date.parse("2029-01-01"),
|
222
|
-
cavalry: nil,
|
223
|
-
exert: "AAA3",
|
224
|
-
pension: Date.parse("2029-09-10"),
|
225
|
-
thermal: "USD",
|
226
|
-
swung: 999,
|
227
|
-
tipping: "XY342",
|
228
|
-
uncombed: "AAA333AAA333AAA333",
|
229
|
-
tactical: "Barber boy",
|
230
|
-
thyself: "Evil Cackle",
|
231
|
-
race: [
|
232
|
-
{
|
233
|
-
gully: 2,
|
234
|
-
snarl: "dry",
|
235
|
-
avatar: nil,
|
236
|
-
bulge: 2104.92,
|
237
|
-
chosen: "AAA",
|
238
|
-
},
|
239
|
-
{
|
240
|
-
gully: 3,
|
241
|
-
snarl: "pony",
|
242
|
-
avatar: nil,
|
243
|
-
bulge: 2104.92,
|
244
|
-
chosen: "AAA",
|
245
|
-
},
|
246
|
-
],
|
247
|
-
blitz: 432252,
|
248
|
-
},
|
249
|
-
],
|
250
|
-
"late" => false,
|
251
|
-
}).to eq({
|
252
|
-
"slasher" => [
|
253
|
-
{
|
254
|
-
tigress: 4,
|
255
|
-
coffee: Date.parse("2029-01-01"),
|
256
|
-
cavalry: nil,
|
257
|
-
exert: "AAA3",
|
258
|
-
pension: Date.parse("2029-09-10"),
|
259
|
-
thermal: "USD",
|
260
|
-
swung: 999,
|
261
|
-
tipping: "XY342",
|
262
|
-
uncombed: "AAA333AAA333AAA333",
|
263
|
-
tactical: "Barber boy",
|
264
|
-
thyself: "Evil Cackle",
|
265
|
-
race: [
|
266
|
-
{
|
267
|
-
gully: 2,
|
268
|
-
snarl: "dry",
|
269
|
-
avatar: nil,
|
270
|
-
bulge: 2104.92,
|
271
|
-
chosen: "AAA",
|
272
|
-
},
|
273
|
-
{
|
274
|
-
gully: 3,
|
275
|
-
snarl: "pony",
|
276
|
-
avatar: nil,
|
277
|
-
bulge: 2104.92,
|
278
|
-
chosen: "AAA",
|
279
|
-
},
|
280
|
-
],
|
281
|
-
blitz: 4523.643,
|
282
|
-
},
|
283
|
-
],
|
284
|
-
"late" => true,
|
285
|
-
})
|
286
|
-
end
|
287
|
-
|
288
|
-
it "more keys than lcs context, empty ish diff" do
|
289
|
-
expect({
|
290
|
-
"slasher" => [
|
291
|
-
{
|
292
|
-
race: [
|
293
|
-
{}, {},
|
294
|
-
],
|
295
|
-
},
|
296
|
-
],
|
297
|
-
}).to eq({
|
298
|
-
"slasher" => [
|
299
|
-
{
|
300
|
-
tigress: 4,
|
301
|
-
coffee: Date.parse("2029-01-01"),
|
302
|
-
cavalry: nil,
|
303
|
-
exert: "AAA3",
|
304
|
-
pension: Date.parse("2029-09-10"),
|
305
|
-
thermal: "USD",
|
306
|
-
swung: 999,
|
307
|
-
tipping: "XY342",
|
308
|
-
uncombed: "AAA333AAA333AAA333",
|
309
|
-
tactical: "Barber boy",
|
310
|
-
thyself: "Evil Cackle",
|
311
|
-
race: [
|
312
|
-
{
|
313
|
-
gully: 2,
|
314
|
-
snarl: "dry",
|
315
|
-
avatar: nil,
|
316
|
-
bulge: 2104.92,
|
317
|
-
chosen: "AAA",
|
318
|
-
},
|
319
|
-
{
|
320
|
-
gully: 3,
|
321
|
-
snarl: "pony",
|
322
|
-
avatar: nil,
|
323
|
-
bulge: 2104.92,
|
324
|
-
chosen: "AAA",
|
325
|
-
},
|
326
|
-
],
|
327
|
-
blitz: 4523.643,
|
328
|
-
},
|
329
|
-
],
|
330
|
-
"late" => true,
|
331
|
-
})
|
332
|
-
end
|
333
|
-
|
334
|
-
it "hash with procs and other weird objects" do
|
335
|
-
expect({
|
336
|
-
test: ->(a, b) { puts a; puts b },
|
337
|
-
x: "42",
|
338
|
-
}).to eq({
|
339
|
-
test: lambda do sleep 1 end,
|
340
|
-
x: "43",
|
341
|
-
})
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
it "hash vs nil" do
|
346
|
-
expect({a: :b}).to eq(nil)
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
describe "eql" do
|
351
|
-
it "strings" do
|
352
|
-
s1 = <<~MSG
|
353
|
-
this is gtex
|
354
|
-
pweoekeoekwpef
|
355
|
-
|
356
|
-
cam shaft motorway
|
357
|
-
ca shaft morord day
|
358
|
-
|
359
|
-
video games
|
360
|
-
MSG
|
361
|
-
|
362
|
-
s2 = <<~MSG
|
363
|
-
rthoijserg
|
364
|
-
erg
|
365
|
-
sehg
|
366
|
-
earg
|
367
|
-
ersgerg
|
368
|
-
MSG
|
369
|
-
|
370
|
-
expect(s1).to eql(s2)
|
371
|
-
end
|
372
|
-
|
373
|
-
it "hashes" do
|
374
|
-
hash1 = {
|
375
|
-
a: {a: {a: {a: [1, 2, 3]}}},
|
376
|
-
b: :x,
|
377
|
-
}
|
378
|
-
hash2 = {
|
379
|
-
a: {a: {b: {a: [1, 2, 3]}}},
|
380
|
-
b: :x,
|
381
|
-
}
|
382
|
-
|
383
|
-
expect(hash1).to eql(hash2)
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
describe "equal" do
|
388
|
-
it "different strings" do
|
389
|
-
s1 = <<~MSG
|
390
|
-
this is gtex
|
391
|
-
pweoekeoekwpef
|
392
|
-
|
393
|
-
cam shaft motorway
|
394
|
-
ca shaft morord day
|
395
|
-
|
396
|
-
video games
|
397
|
-
MSG
|
398
|
-
|
399
|
-
s2 = <<~MSG
|
400
|
-
rthoijserg
|
401
|
-
erg
|
402
|
-
sehg
|
403
|
-
earg
|
404
|
-
ersgerg
|
405
|
-
MSG
|
406
|
-
|
407
|
-
expect(s1).to equal(s2)
|
408
|
-
end
|
409
|
-
|
410
|
-
it "different hashes" do
|
411
|
-
hash1 = {
|
412
|
-
a: {a: {a: {a: [1, 2, 3]}}},
|
413
|
-
b: :x,
|
414
|
-
}
|
415
|
-
hash2 = {
|
416
|
-
a: {a: {b: {a: [1, 2, 3]}}},
|
417
|
-
b: :x,
|
418
|
-
}
|
419
|
-
|
420
|
-
expect(hash1).to equal(hash2)
|
421
|
-
end
|
422
|
-
|
423
|
-
it "same strings" do
|
424
|
-
s1 = <<~MSG
|
425
|
-
rthoijserg
|
426
|
-
erg
|
427
|
-
sehg
|
428
|
-
earg
|
429
|
-
ersgerg
|
430
|
-
MSG
|
431
|
-
|
432
|
-
s2 = <<~MSG
|
433
|
-
rthoijserg
|
434
|
-
erg
|
435
|
-
sehg
|
436
|
-
earg
|
437
|
-
ersgerg
|
438
|
-
MSG
|
439
|
-
|
440
|
-
expect(s1).to equal(s2)
|
441
|
-
end
|
442
|
-
|
443
|
-
it "same hashes" do
|
444
|
-
hash1 = {
|
445
|
-
a: {a: {a: {a: [1, 2, 3]}}},
|
446
|
-
b: :x,
|
447
|
-
}
|
448
|
-
hash2 = {
|
449
|
-
a: {a: {a: {a: [1, 2, 3]}}},
|
450
|
-
b: :x,
|
451
|
-
}
|
452
|
-
|
453
|
-
expect(hash1).to equal(hash2)
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
describe "have_attributes" do
|
458
|
-
it "two symbol keys" do
|
459
|
-
klass = Class.new do
|
460
|
-
def hibernate
|
461
|
-
"yes"
|
462
|
-
end
|
463
|
-
def sawblade
|
464
|
-
34
|
465
|
-
end
|
466
|
-
def ignored
|
467
|
-
/haha/
|
468
|
-
end
|
469
|
-
end
|
470
|
-
instance = klass.new
|
471
|
-
|
472
|
-
expect(instance).to have_attributes({hibernate: "yes", sawblade: 34})
|
473
|
-
|
474
|
-
# no diff when missing an attribute, since it just complains that the
|
475
|
-
# object doesn't respond
|
476
|
-
# expect(instance).to have_attributes({
|
477
|
-
# bong: :bing,
|
478
|
-
# bang: :bling,
|
479
|
-
# song: :sing,
|
480
|
-
# hibernate: 42,
|
481
|
-
# })
|
482
|
-
expect(instance).to have_attributes({
|
483
|
-
hibernate: "no", sawblade: 33,
|
484
|
-
})
|
485
|
-
end
|
486
|
-
|
487
|
-
it "two string keys" do
|
488
|
-
klass = Class.new do
|
489
|
-
def hibernate
|
490
|
-
"yes"
|
491
|
-
end
|
492
|
-
def sawblade
|
493
|
-
34
|
494
|
-
end
|
495
|
-
def ignored
|
496
|
-
/haha/
|
497
|
-
end
|
498
|
-
end
|
499
|
-
instance = klass.new
|
500
|
-
|
501
|
-
expect(instance).to have_attributes({"hibernate" => "yes", "sawblade" => 34})
|
502
|
-
|
503
|
-
# expect(instance).to have_attributes({
|
504
|
-
# bong: :bing,
|
505
|
-
# bang: :bling,
|
506
|
-
# song: :sing,
|
507
|
-
# hibernate: 42,
|
508
|
-
# })
|
509
|
-
expect(instance).to have_attributes({
|
510
|
-
"hibernate" => "no", "sawblade" => 33,
|
511
|
-
})
|
512
|
-
end
|
513
|
-
end
|
514
|
-
|
515
|
-
describe "include" do
|
516
|
-
it "array numbers" do
|
517
|
-
expect([1, 2]).to include(1, 4, 2, 3)
|
518
|
-
end
|
519
|
-
|
520
|
-
it "multiline strings" do
|
521
|
-
string = <<~TXT
|
522
|
-
aaaaa
|
523
|
-
|
524
|
-
bbbbbc
|
525
|
-
cc
|
526
|
-
deeee
|
527
|
-
heee
|
528
|
-
TXT
|
529
|
-
|
530
|
-
expect(string).to include("cc\ndeed")
|
531
|
-
end
|
532
|
-
|
533
|
-
it "2 multiline strings" do
|
534
|
-
string = <<~TXT
|
535
|
-
aaaaa
|
536
|
-
|
537
|
-
bbbbbc
|
538
|
-
cc
|
539
|
-
deeee
|
540
|
-
heee
|
541
|
-
TXT
|
542
|
-
|
543
|
-
expect(string).to include("cc\ndeed", "e\nhehe")
|
544
|
-
end
|
545
|
-
|
546
|
-
it "shallow hash" do
|
547
|
-
hash = {
|
548
|
-
a: :b,
|
549
|
-
c: "d",
|
550
|
-
e: 3,
|
551
|
-
}
|
552
|
-
|
553
|
-
expect(hash).to include("d")
|
554
|
-
end
|
555
|
-
|
556
|
-
# hmm interesting. doesn't look too good, but still a little better than
|
557
|
-
# default rspec
|
558
|
-
it "shallow nested hash" do
|
559
|
-
hash = {
|
560
|
-
a: :b,
|
561
|
-
c: {
|
562
|
-
ve: "lu",
|
563
|
-
mm: "hmm",
|
564
|
-
},
|
565
|
-
e: 3,
|
566
|
-
}
|
567
|
-
|
568
|
-
expect(hash).to include({c: {mm: "hmmm", ve: "le"}})
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
describe "match" do
|
573
|
-
it "single line string against regex" do
|
574
|
-
expect("tootsie fall").to match(/oot.+fals/)
|
575
|
-
end
|
576
|
-
|
577
|
-
it "single line string against string" do
|
578
|
-
expect("tootsie fall").to match("ootsflas")
|
579
|
-
end
|
580
|
-
|
581
|
-
it "multi line string against regex" do
|
582
|
-
expect("tootsie\nwitsy\nmatsy\nmoe").to match(/wity.+matty/)
|
583
|
-
end
|
584
|
-
|
585
|
-
it "mutli line string against string" do
|
586
|
-
expect("tootsie\nwitsy\nmatsy\nmoe").to match("sie\nwitsy\nsds")
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
describe "output" do
|
591
|
-
it "single line string against regex" do
|
592
|
-
expect { $stdout.puts "ninja simulator sickness" }
|
593
|
-
.to output(/ninsim/).to_stdout
|
594
|
-
end
|
595
|
-
|
596
|
-
it "single line string against string" do
|
597
|
-
expect { $stdout.puts "ninja simulator sickness" }
|
598
|
-
.to output("ninsim").to_stdout
|
599
|
-
end
|
600
|
-
|
601
|
-
it "multi line string against regex" do
|
602
|
-
expect { $stdout.puts "ninja\nsimulator\nsickness" }
|
603
|
-
.to output(/sim.+sicns/).to_stdout
|
604
|
-
end
|
605
|
-
|
606
|
-
it "mutli line string against string" do
|
607
|
-
expect { $stdout.puts "ninja\nsimulator\nsickness" }
|
608
|
-
.to output("ninja\nsim\soicns").to_stdout
|
609
|
-
end
|
610
|
-
end
|
611
|
-
|
612
|
-
describe "custom matcher" do
|
613
|
-
RSpec::Matchers.define :my_cool_matcher do |expected|
|
614
|
-
match do |actual|
|
615
|
-
expected = "my\nsuper\ncool\nstring\nyo"
|
616
|
-
|
617
|
-
actual == expected
|
618
|
-
end
|
619
|
-
|
620
|
-
def diffable?
|
621
|
-
true
|
622
|
-
end
|
623
|
-
end
|
624
|
-
|
625
|
-
it "string" do
|
626
|
-
expect("my string").to my_cool_matcher
|
627
|
-
end
|
628
|
-
|
629
|
-
it "mutli line string" do
|
630
|
-
expect("my\nnot\nvery\ncool\nstring").to my_cool_matcher
|
631
|
-
end
|
632
|
-
end
|
633
|
-
|
634
|
-
# inspect integration test
|
635
|
-
it "all the types" do
|
636
|
-
# object ids like 0x00007f1da833a4d8 that change every test run are not
|
637
|
-
# practical, so you should assume any type not tested here returns whatever
|
638
|
-
# #inspect gives
|
639
|
-
inspecty_boi = Object.new
|
640
|
-
def inspecty_boi.inspect
|
641
|
-
"<Inspecty boi>"
|
642
|
-
end
|
643
|
-
|
644
|
-
# these don't have an #inspect
|
645
|
-
basic_object = MyBasicObjectClass.new
|
646
|
-
inspect_was_undefd = ConstantForTheSolePurposeOfUndefiningInspect.new
|
647
|
-
|
648
|
-
basic_object2_klass = Class.new(BasicObject)
|
649
|
-
basic_object2 = basic_object2_klass.new
|
650
|
-
|
651
|
-
expect({
|
652
|
-
string: "string HO \"",
|
653
|
-
"symbol" => :lol,
|
654
|
-
symbol: :symbol,
|
655
|
-
regex: /lo?([a-d])l/i,
|
656
|
-
int: 2,
|
657
|
-
float: 2.45,
|
658
|
-
infinity_plus: Float::INFINITY,
|
659
|
-
infinity_minus: -Float::INFINITY,
|
660
|
-
nan: Float::NAN,
|
661
|
-
big_number_yo: 95_023_569_498_234_210_594_598_234_509_320_923_450_893_425,
|
662
|
-
rational: Rational("2/12"),
|
663
|
-
bigdecimal: BigDecimal("45462345.62346452342342131353467899991112454"),
|
664
|
-
nothing: nil,
|
665
|
-
truth: true,
|
666
|
-
falsehood: false,
|
667
|
-
array: [],
|
668
|
-
hash: {},
|
669
|
-
time: Time.new(2000, 1, 1, 5, 34, 1, "+02:00"),
|
670
|
-
date: Date.new(1999, 12, 31),
|
671
|
-
datetime: DateTime.new(2001, 2, 3, 4, 5, 6, "+0700"),
|
672
|
-
fallback_to_inspect: inspecty_boi,
|
673
|
-
uninspectable1: basic_object,
|
674
|
-
uninspectable2: inspect_was_undefd,
|
675
|
-
uninspectable3: basic_object2,
|
676
|
-
}).to eq({})
|
677
|
-
end
|
678
|
-
end
|