much-stub 0.1.6 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,15 +16,21 @@ module MuchStub
16
16
  @orig_value = Factory.string
17
17
  @stub_value = Factory.string
18
18
 
19
- @myclass = Class.new do
20
- def initialize(value); @value = value; end
21
- def mymeth; @value; end
22
- end
19
+ @myclass =
20
+ Class.new do
21
+ def initialize(value)
22
+ @value = value
23
+ end
24
+
25
+ def mymeth
26
+ @value
27
+ end
28
+ end
23
29
  @myobj = @myclass.new(@orig_value)
24
30
  end
25
31
 
26
32
  should "build a stub" do
27
- stub1 = MuchStub.(@myobj, :mymeth)
33
+ stub1 = MuchStub.call(@myobj, :mymeth)
28
34
  assert_kind_of MuchStub::Stub, stub1
29
35
 
30
36
  stub2 = MuchStub.stub(@myobj, :mymeth)
@@ -34,9 +40,9 @@ module MuchStub
34
40
  should "build a stub with an on_call block" do
35
41
  my_meth_called_with = nil
36
42
  stub1 =
37
- MuchStub.on_call(@myobj, :mymeth) { |call|
43
+ MuchStub.on_call(@myobj, :mymeth) do |call|
38
44
  my_meth_called_with = call
39
- }
45
+ end
40
46
 
41
47
  @myobj.mymeth
42
48
  assert_kind_of MuchStub::Stub, stub1
@@ -44,9 +50,9 @@ module MuchStub
44
50
 
45
51
  my_meth_called_with = nil
46
52
  stub2 =
47
- MuchStub.stub_on_call(@myobj, :mymeth) { |call|
53
+ MuchStub.stub_on_call(@myobj, :mymeth) do |call|
48
54
  my_meth_called_with = call
49
- }
55
+ end
50
56
 
51
57
  @myobj.mymeth
52
58
  assert_kind_of MuchStub::Stub, stub2
@@ -54,15 +60,15 @@ module MuchStub
54
60
  end
55
61
 
56
62
  should "lookup stubs that have been called before" do
57
- stub1 = MuchStub.(@myobj, :mymeth)
58
- stub2 = MuchStub.(@myobj, :mymeth)
63
+ stub1 = MuchStub.call(@myobj, :mymeth)
64
+ stub2 = MuchStub.call(@myobj, :mymeth)
59
65
  assert_same stub1, stub2
60
66
  end
61
67
 
62
68
  should "set the stub's do block if given a block" do
63
- MuchStub.(@myobj, :mymeth)
69
+ MuchStub.call(@myobj, :mymeth)
64
70
  assert_raises(MuchStub::NotStubbedError){ @myobj.mymeth }
65
- MuchStub.(@myobj, :mymeth){ @stub_value }
71
+ MuchStub.call(@myobj, :mymeth){ @stub_value }
66
72
  assert_equal @stub_value, @myobj.mymeth
67
73
  end
68
74
 
@@ -72,7 +78,7 @@ module MuchStub
72
78
  assert_equal @orig_value, @myobj.mymeth
73
79
 
74
80
  assert_equal @orig_value, @myobj.mymeth
75
- MuchStub.(@myobj, :mymeth){ @stub_value }
81
+ MuchStub.call(@myobj, :mymeth){ @stub_value }
76
82
  assert_equal @stub_value, @myobj.mymeth
77
83
  MuchStub.unstub(@myobj, :mymeth)
78
84
  assert_equal @orig_value, @myobj.mymeth
@@ -81,7 +87,7 @@ module MuchStub
81
87
  should "know and teardown all stubs" do
82
88
  assert_equal @orig_value, @myobj.mymeth
83
89
 
84
- MuchStub.(@myobj, :mymeth){ @stub_value }
90
+ MuchStub.call(@myobj, :mymeth){ @stub_value }
85
91
  assert_equal @stub_value, @myobj.mymeth
86
92
  assert_equal 1, MuchStub.stubs.size
87
93
 
@@ -91,11 +97,14 @@ module MuchStub
91
97
  end
92
98
 
93
99
  should "be able to call a stub's original method" do
94
- err = assert_raises(NotStubbedError){ MuchStub.stub_send(@myobj, :mymeth) }
100
+ err =
101
+ assert_raises(NotStubbedError) do
102
+ MuchStub.stub_send(@myobj, :mymeth)
103
+ end
95
104
  assert_includes "not stubbed.", err.message
96
105
  assert_includes "test/unit/much-stub_tests.rb", err.backtrace.first
97
106
 
98
- MuchStub.(@myobj, :mymeth){ @stub_value }
107
+ MuchStub.call(@myobj, :mymeth){ @stub_value }
99
108
 
100
109
  assert_equal @stub_value, @myobj.mymeth
101
110
  assert_equal @orig_value, MuchStub.stub_send(@myobj, :mymeth)
@@ -103,9 +112,9 @@ module MuchStub
103
112
 
104
113
  should "be able to add a stub tap" do
105
114
  my_meth_called_with = nil
106
- MuchStub.tap(@myobj, :mymeth){ |value, *args, &block|
115
+ MuchStub.tap(@myobj, :mymeth) do |_value, *args|
107
116
  my_meth_called_with = args
108
- }
117
+ end
109
118
 
110
119
  assert_equal @orig_value, @myobj.mymeth
111
120
  assert_equal [], my_meth_called_with
@@ -113,21 +122,33 @@ module MuchStub
113
122
 
114
123
  should "be able to add a stub tap with an on_call block" do
115
124
  my_meth_called_with = nil
116
- MuchStub.tap_on_call(@myobj, :mymeth){ |value, call|
125
+ MuchStub.tap_on_call(@myobj, :mymeth) do |_value, call|
117
126
  my_meth_called_with = call
118
- }
127
+ end
119
128
 
120
129
  assert_equal @orig_value, @myobj.mymeth
121
130
  assert_equal [], my_meth_called_with.args
122
131
  end
123
132
 
124
133
  should "be able to add a stubbed spy" do
125
- myclass = Class.new do
126
- def one; self; end
127
- def two(val); self; end
128
- def three; self; end
129
- def ready?; false; end
130
- end
134
+ myclass =
135
+ Class.new do
136
+ def one
137
+ self
138
+ end
139
+
140
+ def two(_val)
141
+ self
142
+ end
143
+
144
+ def three
145
+ self
146
+ end
147
+
148
+ def ready?
149
+ false
150
+ end
151
+ end
131
152
  myobj = myclass.new
132
153
 
133
154
  spy =
@@ -137,7 +158,8 @@ module MuchStub
137
158
  :two,
138
159
  :three,
139
160
  :to_s,
140
- ready?: true)
161
+ ready?: true,
162
+ )
141
163
 
142
164
  assert_equal spy, myobj.one
143
165
  assert_equal spy, myobj.two("a")
@@ -160,13 +182,32 @@ module MuchStub
160
182
  class StubTests < UnitTests
161
183
  desc "Stub"
162
184
  setup do
163
- @myclass = Class.new do
164
- def mymeth; "meth"; end
165
- def myval(val); val; end
166
- def myargs(*args); args; end
167
- def myvalargs(val1, val2, *args); [val1, val2, args]; end
168
- def myblk(&block); block.call; end
169
- end
185
+ @myclass =
186
+ Class.new do
187
+ def mymeth
188
+ "meth"
189
+ end
190
+
191
+ def myval(val)
192
+ val
193
+ end
194
+
195
+ def myargs(*args)
196
+ args
197
+ end
198
+
199
+ def myvalargs(val1, val2, *args)
200
+ [val1, val2, args]
201
+ end
202
+
203
+ def mykargs(val1:, **kargs)
204
+ [val1, kargs]
205
+ end
206
+
207
+ def myblk(&block)
208
+ block.call
209
+ end
210
+ end
170
211
  @myobj = @myclass.new
171
212
 
172
213
  @stub = MuchStub::Stub.new(@myobj, :mymeth)
@@ -181,7 +222,10 @@ module MuchStub
181
222
  should "generate a key given an object and method name" do
182
223
  obj = @myobj
183
224
  meth = :mymeth
184
- assert_equal "--#{obj.object_id}--#{meth}--", MuchStub::Stub.key(obj, meth)
225
+ assert_equal(
226
+ "--#{obj.object_id}--#{meth}--",
227
+ MuchStub::Stub.key(obj, meth),
228
+ )
185
229
  end
186
230
 
187
231
  should "know its names" do
@@ -218,67 +262,72 @@ module MuchStub
218
262
  end
219
263
 
220
264
  should "complain if stubbing a method that the object doesn't respond to" do
221
- err = assert_raises(MuchStub::StubError){ MuchStub::Stub.new(@myobj, :some_other_meth) }
222
- assert_includes "does not respond to", err.message
265
+ err =
266
+ assert_raises(MuchStub::StubError) do
267
+ MuchStub::Stub.new(@myobj, :some_other_meth)
268
+ end
269
+ assert_includes "does not respond to", err.message
223
270
  assert_includes "test/unit/much-stub_tests.rb", err.backtrace.first
224
271
  end
225
272
 
226
273
  should "complain if stubbed and called with mismatched arity" do
227
274
  MuchStub::Stub.new(@myobj, :myval){ "myval" }
228
275
  err = assert_raises(MuchStub::StubArityError){ @myobj.myval }
229
- assert_includes "arity mismatch on", err.message
276
+ assert_includes "arity mismatch on", err.message
230
277
  assert_includes "test/unit/much-stub_tests.rb", err.backtrace.first
231
278
 
232
- assert_nothing_raised { @myobj.myval(1) }
233
- assert_raises(MuchStub::StubArityError){ @myobj.myval(1,2) }
279
+ assert_nothing_raised{ @myobj.myval(1) }
280
+ assert_raises(MuchStub::StubArityError){ @myobj.myval(1, 2) }
234
281
 
235
282
  MuchStub::Stub.new(@myobj, :myargs){ "myargs" }
236
- assert_nothing_raised { @myobj.myargs }
237
- assert_nothing_raised { @myobj.myargs(1) }
238
- assert_nothing_raised { @myobj.myargs(1,2) }
283
+ assert_nothing_raised{ @myobj.myargs }
284
+ assert_nothing_raised{ @myobj.myargs(1) }
285
+ assert_nothing_raised{ @myobj.myargs(1, 2) }
239
286
 
240
287
  MuchStub::Stub.new(@myobj, :myvalargs){ "myvalargs" }
241
288
  assert_raises(MuchStub::StubArityError){ @myobj.myvalargs }
242
289
  assert_raises(MuchStub::StubArityError){ @myobj.myvalargs(1) }
243
- assert_nothing_raised { @myobj.myvalargs(1,2) }
244
- assert_nothing_raised { @myobj.myvalargs(1,2,3) }
290
+ assert_nothing_raised{ @myobj.myvalargs(1, 2) }
291
+ assert_nothing_raised{ @myobj.myvalargs(1, nil) }
292
+ assert_nothing_raised{ @myobj.myvalargs(1, 2, 3) }
245
293
  end
246
294
 
247
295
  should "complain if stubbed with mismatched arity" do
248
- err = assert_raises(MuchStub::StubArityError) do
249
- MuchStub::Stub.new(@myobj, :myval).with(){ "myval" }
250
- end
251
- assert_includes "arity mismatch on", err.message
296
+ err =
297
+ assert_raises(MuchStub::StubArityError) do
298
+ MuchStub::Stub.new(@myobj, :myval).with{ "myval" }
299
+ end
300
+ assert_includes "arity mismatch on", err.message
252
301
  assert_includes "test/unit/much-stub_tests.rb", err.backtrace.first
253
302
 
254
303
  assert_raises(MuchStub::StubArityError) do
255
- MuchStub::Stub.new(@myobj, :myval).with(1,2){ "myval" }
304
+ MuchStub::Stub.new(@myobj, :myval).with(1, 2){ "myval" }
256
305
  end
257
306
  assert_nothing_raised do
258
307
  MuchStub::Stub.new(@myobj, :myval).with(1){ "myval" }
259
308
  end
260
309
 
261
310
  assert_nothing_raised do
262
- MuchStub::Stub.new(@myobj, :myargs).with(){ "myargs" }
311
+ MuchStub::Stub.new(@myobj, :myargs).with{ "myargs" }
263
312
  end
264
313
  assert_nothing_raised do
265
- MuchStub::Stub.new(@myobj, :myargs).with(1,2){ "myargs" }
314
+ MuchStub::Stub.new(@myobj, :myargs).with(1, 2){ "myargs" }
266
315
  end
267
316
  assert_nothing_raised do
268
317
  MuchStub::Stub.new(@myobj, :myargs).with(1){ "myargs" }
269
318
  end
270
319
 
271
320
  assert_raises(MuchStub::StubArityError) do
272
- MuchStub::Stub.new(@myobj, :myvalargs).with(){ "myvalargs" }
321
+ MuchStub::Stub.new(@myobj, :myvalargs).with{ "myvalargs" }
273
322
  end
274
323
  assert_raises(MuchStub::StubArityError) do
275
324
  MuchStub::Stub.new(@myobj, :myvalargs).with(1){ "myvalargs" }
276
325
  end
277
326
  assert_nothing_raised do
278
- MuchStub::Stub.new(@myobj, :myvalargs).with(1,2){ "myvalargs" }
327
+ MuchStub::Stub.new(@myobj, :myvalargs).with(1, 2){ "myvalargs" }
279
328
  end
280
329
  assert_nothing_raised do
281
- MuchStub::Stub.new(@myobj, :myvalargs).with(1,2,3){ "myvalargs" }
330
+ MuchStub::Stub.new(@myobj, :myvalargs).with(1, 2, 3){ "myvalargs" }
282
331
  end
283
332
  end
284
333
 
@@ -292,7 +341,7 @@ module MuchStub
292
341
 
293
342
  should "stub methods with required arg" do
294
343
  assert_equal 1, @myobj.myval(1)
295
- stub = MuchStub::Stub.new(@myobj, :myval){ |val| val.to_s }
344
+ stub = MuchStub::Stub.new(@myobj, :myval, &:to_s)
296
345
  assert_equal "1", @myobj.myval(1)
297
346
  assert_equal "2", @myobj.myval(2)
298
347
  stub.with(2){ "two" }
@@ -300,30 +349,36 @@ module MuchStub
300
349
  end
301
350
 
302
351
  should "stub methods with variable args" do
303
- assert_equal [1,2], @myobj.myargs(1,2)
352
+ assert_equal [1, 2], @myobj.myargs(1, 2)
304
353
 
305
354
  stub = MuchStub::Stub.new(@myobj, :myargs){ |*args| args.join(",") }
306
- assert_equal "1,2,3", @myobj.myargs(1,2,3)
307
- stub.with(3,4,5){ |*args| args.join(":") }
308
- assert_equal "3:4:5", @myobj.myargs(3,4,5)
355
+ assert_equal "1,2,3", @myobj.myargs(1, 2, 3)
356
+ stub.with(3, 4, 5){ |*args| args.join(":") }
357
+ assert_equal "3:4:5", @myobj.myargs(3, 4, 5)
309
358
 
310
- stub = MuchStub::Stub.new(@myobj, :myargs).on_call{ |call| call.args.join(",") }
311
- assert_equal "1,2,3", @myobj.myargs(1,2,3)
312
- stub.with(3,4,5).on_call{ |call| call.args.join(":") }
313
- assert_equal "3:4:5", @myobj.myargs(3,4,5)
359
+ stub =
360
+ MuchStub::Stub.new(@myobj, :myargs).on_call do |call|
361
+ call.args.join(",")
362
+ end
363
+ assert_equal "1,2,3", @myobj.myargs(1, 2, 3)
364
+ stub.with(3, 4, 5).on_call{ |call| call.args.join(":") }
365
+ assert_equal "3:4:5", @myobj.myargs(3, 4, 5)
314
366
  end
315
367
 
316
368
  should "stub methods with required args and variable args" do
317
- assert_equal [1,2, [3]], @myobj.myvalargs(1,2,3)
369
+ assert_equal [1, 2, [3]], @myobj.myvalargs(1, 2, 3)
318
370
  stub = MuchStub::Stub.new(@myobj, :myvalargs){ |*args| args.join(",") }
319
- assert_equal "1,2,3", @myobj.myvalargs(1,2,3)
320
- stub.with(3,4,5){ |*args| args.join(":") }
321
- assert_equal "3:4:5", @myobj.myvalargs(3,4,5)
371
+ assert_equal "1,2,3", @myobj.myvalargs(1, 2, 3)
372
+ stub.with(3, 4, 5){ |*args| args.join(":") }
373
+ assert_equal "3:4:5", @myobj.myvalargs(3, 4, 5)
322
374
 
323
- stub = MuchStub::Stub.new(@myobj, :myvalargs).on_call{ |call| call.args.join(",") }
324
- assert_equal "1,2,3", @myobj.myvalargs(1,2,3)
325
- stub.with(3,4,5).on_call{ |call| call.args.join(":") }
326
- assert_equal "3:4:5", @myobj.myvalargs(3,4,5)
375
+ stub =
376
+ MuchStub::Stub.new(@myobj, :myvalargs).on_call do |call|
377
+ call.args.join(",")
378
+ end
379
+ assert_equal "1,2,3", @myobj.myvalargs(1, 2, 3)
380
+ stub.with(3, 4, 5).on_call{ |call| call.args.join(":") }
381
+ assert_equal "3:4:5", @myobj.myvalargs(3, 4, 5)
327
382
  end
328
383
 
329
384
  should "stub methods that yield blocks" do
@@ -339,25 +394,32 @@ module MuchStub
339
394
  end
340
395
 
341
396
  should "stub methods even if they are not local to the object" do
342
- mydelegatorclass = Class.new do
343
- def initialize(delegateclass)
344
- @delegate = delegateclass.new
345
- end
346
- def respond_to?(meth)
347
- @delegate.respond_to?(meth) || super
397
+ mydelegatorclass =
398
+ Class.new do
399
+ def initialize(delegateclass)
400
+ @delegate = delegateclass.new
401
+ end
402
+
403
+ def respond_to?(meth)
404
+ @delegate.respond_to?(meth) || super
405
+ end
406
+
407
+ def method_missing(meth, *args, &block)
408
+ respond_to?(meth) ? @delegate.send(meth, *args, &block) : super
409
+ end
410
+
411
+ def respond_to_missing?(meth, _)
412
+ respond_to?(meth) || super
413
+ end
348
414
  end
349
- def method_missing(meth, *args, &block)
350
- respond_to?(meth) ? @delegate.send(meth, *args, &block) : super
351
- end
352
- end
353
415
  mydelegator = mydelegatorclass.new(@myclass)
354
416
 
355
- assert_equal [1,2,[3]], mydelegator.myvalargs(1,2,3)
417
+ assert_equal [1, 2, [3]], mydelegator.myvalargs(1, 2, 3)
356
418
  stub = MuchStub::Stub.new(mydelegator, :myvalargs){ |*args| args.inspect }
357
- assert_equal "[1, 2, 3]", mydelegator.myvalargs(1,2,3)
358
- assert_equal "[4, 5, 6]", mydelegator.myvalargs(4,5,6)
359
- stub.with(4,5,6){ "four-five-six" }
360
- assert_equal "four-five-six", mydelegator.myvalargs(4,5,6)
419
+ assert_equal "[1, 2, 3]", mydelegator.myvalargs(1, 2, 3)
420
+ assert_equal "[4, 5, 6]", mydelegator.myvalargs(4, 5, 6)
421
+ stub.with(4, 5, 6){ "four-five-six" }
422
+ assert_equal "four-five-six", mydelegator.myvalargs(4, 5, 6)
361
423
  end
362
424
 
363
425
  should "call to the original method" do
@@ -365,46 +427,54 @@ module MuchStub
365
427
 
366
428
  # no args
367
429
  stub = MuchStub::Stub.new(@myobj, :mymeth){ "mymeth" }
368
- assert_equal "mymeth", stub.call([])
369
- assert_equal "meth", stub.call_method([])
430
+ assert_equal "mymeth", stub.call
431
+ assert_equal "meth", stub.call_method
370
432
 
371
433
  # static args
372
- stub = MuchStub::Stub.new(@myobj, :myval){ |val| val.to_s }
373
- assert_equal "1", stub.call([1])
374
- assert_equal 1, stub.call_method([1])
375
- assert_equal "2", stub.call([2])
376
- assert_equal 2, stub.call_method([2])
434
+ stub = MuchStub::Stub.new(@myobj, :myval, &:to_s)
435
+ assert_equal "1", stub.call(1)
436
+ assert_equal 1, stub.call_method(1)
437
+ assert_equal "2", stub.call(2)
438
+ assert_equal 2, stub.call_method(2)
377
439
  stub.with(2){ "two" }
378
- assert_equal "two", stub.call([2])
379
- assert_equal 2, stub.call_method([2])
440
+ assert_equal "two", stub.call(2)
441
+ assert_equal 2, stub.call_method(2)
380
442
 
381
443
  # dynamic args
382
444
  stub = MuchStub::Stub.new(@myobj, :myargs){ |*args| args.join(",") }
383
- assert_equal "1,2", stub.call([1,2])
384
- assert_equal [1,2], stub.call_method([1,2])
385
- assert_equal "3,4,5", stub.call([3,4,5])
386
- assert_equal [3,4,5], stub.call_method([3,4,5])
387
- stub.with(3,4,5){ "three-four-five" }
388
- assert_equal "three-four-five", stub.call([3,4,5])
389
- assert_equal [3,4,5], stub.call_method([3,4,5])
445
+ assert_equal "1,2", stub.call(1, 2)
446
+ assert_equal [1, 2], stub.call_method(1, 2)
447
+ assert_equal "3,4,5", stub.call(3, 4, 5)
448
+ assert_equal [3, 4, 5], stub.call_method(3, 4, 5)
449
+ stub.with(3, 4, 5){ "three-four-five" }
450
+ assert_equal "three-four-five", stub.call(3, 4, 5)
451
+ assert_equal [3, 4, 5], stub.call_method(3, 4, 5)
390
452
 
391
453
  # mixed static/dynamic args
392
454
  stub = MuchStub::Stub.new(@myobj, :myvalargs){ |*args| args.join(",") }
393
- assert_equal "1,2,3", stub.call([1,2,3])
394
- assert_equal [1,2, [3]], stub.call_method([1,2,3])
395
- assert_equal "3,4,5", stub.call([3,4,5])
396
- assert_equal [3,4,[5]], stub.call_method([3,4,5])
397
- stub.with(3,4,5){ "three-four-five" }
398
- assert_equal "three-four-five", stub.call([3,4,5])
399
- assert_equal [3,4,[5]], stub.call_method([3,4,5])
455
+ assert_equal "1,2,3", stub.call(1, 2, 3)
456
+ assert_equal [1, 2, [3]], stub.call_method(1, 2, 3)
457
+ assert_equal "3,4,5", stub.call(3, 4, 5)
458
+ assert_equal [3, 4, [5]], stub.call_method(3, 4, 5)
459
+ stub.with(3, 4, 5){ "three-four-five" }
460
+ assert_equal "three-four-five", stub.call(3, 4, 5)
461
+ assert_equal [3, 4, [5]], stub.call_method(3, 4, 5)
462
+
463
+ # keyword args
464
+ stub = MuchStub::Stub.new(@myobj, :mykargs){ |**kargs| kargs.inspect }
465
+ assert_equal "{:val1=>1, :val2=>2}", stub.call(val1: 1, val2: 2)
466
+ assert_equal [1, { val2: 2 }], stub.call_method(val1: 1, val2: 2)
467
+ stub.with(val1: 3, val2: 4){ "three-four" }
468
+ assert_equal "three-four", stub.call(val1: 3, val2: 4)
469
+ assert_equal [3, { val2: 4 }], stub.call_method(val1: 3, val2: 4)
400
470
 
401
471
  # blocks
402
472
  blkcalled = false
403
473
  blk = proc{ blkcalled = true }
404
474
  stub = MuchStub::Stub.new(@myobj, :myblk){ blkcalled = "true" }
405
- stub.call([], &blk)
475
+ stub.call(&blk)
406
476
  assert_equal "true", blkcalled
407
- stub.call_method([], &blk)
477
+ stub.call_method(&blk)
408
478
  assert_equal true, blkcalled
409
479
  end
410
480
 
@@ -416,16 +486,17 @@ module MuchStub
416
486
 
417
487
  should "be removable" do
418
488
  assert_equal 1, @myobj.myval(1)
419
- stub = MuchStub::Stub.new(@myobj, :myval){ |val| val.to_s }
489
+ stub = MuchStub::Stub.new(@myobj, :myval, &:to_s)
420
490
  assert_equal "1", @myobj.myval(1)
421
491
  stub.teardown
422
492
  assert_equal 1, @myobj.myval(1)
423
493
  end
424
494
 
425
495
  should "have a readable inspect" do
426
- expected = "#<#{subject.class}:#{"0x0%x" % (subject.object_id << 1)}" \
427
- " @method_name=#{subject.method_name.inspect}>"
428
- assert_equal expected, subject.inspect
496
+ exp =
497
+ "#<#{subject.class}:#{format("0x0%x", (subject.object_id << 1))}" \
498
+ " @method_name=#{subject.method_name.inspect}>"
499
+ assert_equal exp, subject.inspect
429
500
  end
430
501
  end
431
502
 
@@ -442,7 +513,7 @@ module MuchStub
442
513
  subject{ @stub }
443
514
 
444
515
  should "not raise a stub error when called" do
445
- assert_nothing_raised{ @stub.call([@arg]) }
516
+ assert_nothing_raised{ @stub.call(@arg) }
446
517
  end
447
518
  end
448
519
 
@@ -465,7 +536,8 @@ module MuchStub
465
536
  assert_equal "child", @child_class.new(1, 2)
466
537
  end
467
538
 
468
- should "not raise any errors when tearing down the parent before the child" do
539
+ should "not raise any errors when tearing down the parent before the "\
540
+ "child" do
469
541
  assert_nothing_raised do
470
542
  @parent_stub.teardown
471
543
  @child_stub.teardown
@@ -486,9 +558,9 @@ module MuchStub
486
558
  class ParameterListTests < UnitTests
487
559
  desc "ParameterList"
488
560
  setup do
489
- many_args = (0..ParameterList::LETTERS.size).map do
561
+ many_args = (0..ParameterList::LETTERS.size).map{
490
562
  Assert::Factory.string
491
- end.join(", ")
563
+ }.join(", ")
492
564
  @object = Class.new
493
565
  # use `class_eval` with string to easily define methods with many params
494
566
  @object.class_eval <<-methods
@@ -505,7 +577,7 @@ module MuchStub
505
577
  end
506
578
 
507
579
  should "build a parameter list for a method that takes any args" do
508
- assert_equal "*args, &block", subject.new(@object, "anyargs")
580
+ assert_equal "*pargs, **kargs, &block", subject.new(@object, "anyargs")
509
581
  end
510
582
 
511
583
  should "build a parameter list for a method that takes many args" do
@@ -513,8 +585,10 @@ module MuchStub
513
585
  assert_equal expected, subject.new(@object, "manyargs")
514
586
  end
515
587
 
516
- should "build a parameter list for a method that takes a minimum number of args" do
517
- expected = "#{ParameterList::LETTERS.join(", ")}, aa, *args, &block"
588
+ should "build a parameter list for a method that takes a minimum number "\
589
+ "of args" do
590
+ expected =
591
+ "#{ParameterList::LETTERS.join(", ")}, aa, *pargs, **kargs, &block"
518
592
  assert_equal expected, subject.new(@object, "minargs")
519
593
  end
520
594
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: much-stub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-04 00:00:00.000000000 Z
12
+ date: 2022-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: assert
@@ -17,14 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.19.0
20
+ version: 2.19.7
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 2.19.0
27
+ version: 2.19.7
28
+ - !ruby/object:Gem::Dependency
29
+ name: much-style-guide
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.6.7
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.6.7
28
42
  description: Stubbing API for replacing method calls on objects in test runs.
29
43
  email:
30
44
  - kelly@kellyredding.com
@@ -34,6 +48,10 @@ extensions: []
34
48
  extra_rdoc_files: []
35
49
  files:
36
50
  - ".gitignore"
51
+ - ".l.yml"
52
+ - ".rubocop.yml"
53
+ - ".ruby-version"
54
+ - ".t.yml"
37
55
  - Gemfile
38
56
  - LICENSE
39
57
  - README.md
@@ -60,7 +78,7 @@ require_paths:
60
78
  - lib
61
79
  required_ruby_version: !ruby/object:Gem::Requirement
62
80
  requirements:
63
- - - "~>"
81
+ - - ">="
64
82
  - !ruby/object:Gem::Version
65
83
  version: '2.5'
66
84
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -69,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
87
  - !ruby/object:Gem::Version
70
88
  version: '0'
71
89
  requirements: []
72
- rubygems_version: 3.1.2
90
+ rubygems_version: 3.3.5
73
91
  signing_key:
74
92
  specification_version: 4
75
93
  summary: Stubbing API for replacing method calls on objects in test runs.