much-stub 0.1.5 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "much-stub"
3
5
 
@@ -55,15 +57,15 @@ module MuchStub
55
57
  end
56
58
 
57
59
  should "not allow stubbing methods with invalid arity" do
58
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
60
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
59
61
 
60
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
61
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
62
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
63
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
62
64
 
63
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
64
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
65
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
66
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
65
67
 
66
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
68
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
67
69
  end
68
70
 
69
71
  should "not allow calling methods with invalid arity" do
@@ -128,15 +130,15 @@ module MuchStub
128
130
  end
129
131
 
130
132
  should "not allow stubbing methods with invalid arity" do
131
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
133
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
132
134
 
133
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
134
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
135
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
136
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
135
137
 
136
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
137
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
138
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
139
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
138
140
 
139
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
141
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
140
142
  end
141
143
 
142
144
  should "not allow calling methods with invalid arity" do
@@ -201,15 +203,15 @@ module MuchStub
201
203
  end
202
204
 
203
205
  should "not allow stubbing methods with invalid arity" do
204
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
206
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
205
207
 
206
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
207
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
208
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
209
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
208
210
 
209
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
210
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
211
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
212
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
211
213
 
212
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
214
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
213
215
  end
214
216
 
215
217
  should "not allow calling methods with invalid arity" do
@@ -274,15 +276,15 @@ module MuchStub
274
276
  end
275
277
 
276
278
  should "not allow stubbing methods with invalid arity" do
277
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
279
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
278
280
 
279
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
280
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
281
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
282
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
281
283
 
282
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
283
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
284
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
285
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
284
286
 
285
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
287
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
286
288
  end
287
289
 
288
290
  should "not allow calling methods with invalid arity" do
@@ -348,15 +350,15 @@ module MuchStub
348
350
  end
349
351
 
350
352
  should "not allow stubbing methods with invalid arity" do
351
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
353
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
352
354
 
353
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
354
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
355
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
356
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
355
357
 
356
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
357
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
358
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
359
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
358
360
 
359
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
361
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
360
362
  end
361
363
 
362
364
  should "not allow calling methods with invalid arity" do
@@ -421,15 +423,15 @@ module MuchStub
421
423
  end
422
424
 
423
425
  should "not allow stubbing methods with invalid arity" do
424
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
426
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
425
427
 
426
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
427
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
428
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
429
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
428
430
 
429
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
430
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
431
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
432
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
431
433
 
432
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
434
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
433
435
  end
434
436
 
435
437
  should "not allow calling methods with invalid arity" do
@@ -495,15 +497,15 @@ module MuchStub
495
497
  end
496
498
 
497
499
  should "not allow stubbing methods with invalid arity" do
498
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
500
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
499
501
 
500
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
501
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
502
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
503
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
502
504
 
503
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
504
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
505
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
506
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
505
507
 
506
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
508
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
507
509
  end
508
510
 
509
511
  should "not allow calling methods with invalid arity" do
@@ -568,15 +570,15 @@ module MuchStub
568
570
  end
569
571
 
570
572
  should "allow stubbing methods with invalid arity" do
571
- assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){ } }
573
+ assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
572
574
 
573
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{ } }
574
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
575
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{} }
576
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){} }
575
577
 
576
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{ } }
577
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){ } }
578
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{} }
579
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){} }
578
580
 
579
- assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){ } }
581
+ assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
580
582
  end
581
583
 
582
584
  should "allow calling methods with invalid arity" do
@@ -641,15 +643,15 @@ module MuchStub
641
643
  end
642
644
 
643
645
  should "allow stubbing methods with invalid arity" do
644
- assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){ } }
646
+ assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
645
647
 
646
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{ } }
647
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
648
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{} }
649
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){} }
648
650
 
649
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{ } }
650
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){ } }
651
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{} }
652
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){} }
651
653
 
652
- assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){ } }
654
+ assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
653
655
  end
654
656
 
655
657
  should "allow calling methods with invalid arity" do
@@ -682,37 +684,73 @@ module MuchStub
682
684
  end
683
685
 
684
686
  class TestClass
685
- def self.noargs; end
686
- def self.withargs(a); end
687
- def self.anyargs(*args); end
688
- def self.minargs(a, b, *args); end
689
- def self.withblock(&block); end
690
-
691
- def noargs; end
692
- def withargs(a); end
693
- def anyargs(*args); end
694
- def minargs(a, b, *args); end
695
- def withblock(&block); end
687
+ def self.noargs
688
+ end
689
+
690
+ def self.withargs(a)
691
+ end
692
+
693
+ def self.anyargs(*args)
694
+ end
695
+
696
+ def self.minargs(a, b, *args)
697
+ end
698
+
699
+ def self.withblock(&block)
700
+ end
701
+
702
+ def noargs
703
+ end
704
+
705
+ def withargs(a)
706
+ end
707
+
708
+ def anyargs(*args)
709
+ end
710
+
711
+ def minargs(a, b, *args)
712
+ end
713
+
714
+ def withblock(&block)
715
+ end
696
716
  end
697
717
 
698
718
  module TestModule
699
- def self.noargs; end
700
- def self.withargs(a); end
701
- def self.anyargs(*args); end
702
- def self.minargs(a, b, *args); end
703
- def self.withblock(&block); end
719
+ def self.noargs
720
+ end
721
+
722
+ def self.withargs(a)
723
+ end
724
+
725
+ def self.anyargs(*args)
726
+ end
727
+
728
+ def self.minargs(a, b, *args)
729
+ end
730
+
731
+ def self.withblock(&block)
732
+ end
704
733
  end
705
734
 
706
735
  module TestMixin
707
- def noargs; end
708
- def withargs(a); end
709
- def anyargs(*args); end
710
- def minargs(a, b, *args); end
711
- def withblock(&block); end
736
+ def noargs
737
+ end
738
+
739
+ def withargs(a)
740
+ end
741
+
742
+ def anyargs(*args)
743
+ end
744
+
745
+ def minargs(a, b, *args)
746
+ end
747
+
748
+ def withblock(&block)
749
+ end
712
750
  end
713
751
 
714
752
  class DelegateClass
715
- def self.respond_to?(*args)
753
+ def self.respond_to_missing?(*args)
716
754
  TestClass.respond_to?(*args) || super
717
755
  end
718
756
 
@@ -724,7 +762,7 @@ module MuchStub
724
762
  @delegate = TestClass.new
725
763
  end
726
764
 
727
- def respond_to?(*args)
765
+ def respond_to_missing?(*args)
728
766
  @delegate.respond_to?(*args) || super
729
767
  end
730
768
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "much-stub/call_spy"
3
5
 
@@ -73,7 +75,8 @@ class MuchStub::CallSpy
73
75
  end
74
76
  subject{ @spy }
75
77
 
76
- should "return the given values instead of itself if that method is called" do
78
+ should "return the given values instead of itself if that method is "\
79
+ "called" do
77
80
  assert_false subject.get.set!("value1").any?
78
81
  assert_true subject.get_called?
79
82
  assert_equal ["value1"], subject.set_bang_called_with.args
@@ -85,7 +88,7 @@ class MuchStub::CallSpy
85
88
  desc "when init with return value procs"
86
89
  setup do
87
90
  @result = Factory.boolean
88
- @spy = @unit_class.new(any?: ->(call) { @result })
91
+ @spy = @unit_class.new(any?: ->(_call){ @result })
89
92
  end
90
93
  subject{ @spy }
91
94
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "much-stub/call"
3
5
 
@@ -12,9 +14,9 @@ class MuchStub::Call
12
14
  @pargs = [Factory.string, Factory.integer]
13
15
  @kargs = {
14
16
  one: 1,
15
- two: 2
17
+ two: 2,
16
18
  }
17
- @block = -> {}
19
+ @block = ->{}
18
20
  end
19
21
  end
20
22