much-stub 0.1.6 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.l.yml +8 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/.t.yml +6 -0
- data/Gemfile +3 -1
- data/README.md +40 -35
- data/lib/much-stub/call_spy.rb +26 -25
- data/lib/much-stub/version.rb +1 -1
- data/lib/much-stub.rb +80 -59
- data/much-stub.gemspec +20 -12
- data/test/helper.rb +1 -1
- data/test/system/much-stub_tests.rb +113 -77
- data/test/unit/call_spy_tests.rb +3 -2
- data/test/unit/call_tests.rb +2 -2
- data/test/unit/much-stub_tests.rb +198 -124
- metadata +24 -6
@@ -57,15 +57,15 @@ module MuchStub
|
|
57
57
|
end
|
58
58
|
|
59
59
|
should "not allow stubbing methods with invalid arity" do
|
60
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
60
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
61
61
|
|
62
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
63
|
-
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){} }
|
64
64
|
|
65
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
66
|
-
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){} }
|
67
67
|
|
68
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
68
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
69
69
|
end
|
70
70
|
|
71
71
|
should "not allow calling methods with invalid arity" do
|
@@ -130,15 +130,15 @@ module MuchStub
|
|
130
130
|
end
|
131
131
|
|
132
132
|
should "not allow stubbing methods with invalid arity" do
|
133
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
133
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
134
134
|
|
135
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
136
|
-
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){} }
|
137
137
|
|
138
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
139
|
-
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){} }
|
140
140
|
|
141
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
141
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
142
142
|
end
|
143
143
|
|
144
144
|
should "not allow calling methods with invalid arity" do
|
@@ -203,15 +203,15 @@ module MuchStub
|
|
203
203
|
end
|
204
204
|
|
205
205
|
should "not allow stubbing methods with invalid arity" do
|
206
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
206
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
207
207
|
|
208
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
209
|
-
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){} }
|
210
210
|
|
211
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
212
|
-
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){} }
|
213
213
|
|
214
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
214
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
215
215
|
end
|
216
216
|
|
217
217
|
should "not allow calling methods with invalid arity" do
|
@@ -276,15 +276,15 @@ module MuchStub
|
|
276
276
|
end
|
277
277
|
|
278
278
|
should "not allow stubbing methods with invalid arity" do
|
279
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
279
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
280
280
|
|
281
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
282
|
-
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){} }
|
283
283
|
|
284
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
285
|
-
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){} }
|
286
286
|
|
287
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
287
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
288
288
|
end
|
289
289
|
|
290
290
|
should "not allow calling methods with invalid arity" do
|
@@ -350,15 +350,15 @@ module MuchStub
|
|
350
350
|
end
|
351
351
|
|
352
352
|
should "not allow stubbing methods with invalid arity" do
|
353
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
353
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
354
354
|
|
355
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
356
|
-
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){} }
|
357
357
|
|
358
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
359
|
-
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){} }
|
360
360
|
|
361
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
361
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
362
362
|
end
|
363
363
|
|
364
364
|
should "not allow calling methods with invalid arity" do
|
@@ -423,15 +423,15 @@ module MuchStub
|
|
423
423
|
end
|
424
424
|
|
425
425
|
should "not allow stubbing methods with invalid arity" do
|
426
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
426
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
427
427
|
|
428
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
429
|
-
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){} }
|
430
430
|
|
431
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
432
|
-
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){} }
|
433
433
|
|
434
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
434
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
435
435
|
end
|
436
436
|
|
437
437
|
should "not allow calling methods with invalid arity" do
|
@@ -497,15 +497,15 @@ module MuchStub
|
|
497
497
|
end
|
498
498
|
|
499
499
|
should "not allow stubbing methods with invalid arity" do
|
500
|
-
assert_raises{ MuchStub.stub(subject, :noargs).with(1){
|
500
|
+
assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
|
501
501
|
|
502
|
-
assert_raises{ MuchStub.stub(subject, :withargs).with{
|
503
|
-
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){} }
|
504
504
|
|
505
|
-
assert_raises{ MuchStub.stub(subject, :minargs).with{
|
506
|
-
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){} }
|
507
507
|
|
508
|
-
assert_raises{ MuchStub.stub(subject, :withblock).with(1){
|
508
|
+
assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
|
509
509
|
end
|
510
510
|
|
511
511
|
should "not allow calling methods with invalid arity" do
|
@@ -570,15 +570,15 @@ module MuchStub
|
|
570
570
|
end
|
571
571
|
|
572
572
|
should "allow stubbing methods with invalid arity" do
|
573
|
-
assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){
|
573
|
+
assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
|
574
574
|
|
575
|
-
assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{
|
576
|
-
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){} }
|
577
577
|
|
578
|
-
assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{
|
579
|
-
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){} }
|
580
580
|
|
581
|
-
assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){
|
581
|
+
assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
|
582
582
|
end
|
583
583
|
|
584
584
|
should "allow calling methods with invalid arity" do
|
@@ -643,15 +643,15 @@ module MuchStub
|
|
643
643
|
end
|
644
644
|
|
645
645
|
should "allow stubbing methods with invalid arity" do
|
646
|
-
assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){
|
646
|
+
assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
|
647
647
|
|
648
|
-
assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{
|
649
|
-
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){} }
|
650
650
|
|
651
|
-
assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{
|
652
|
-
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){} }
|
653
653
|
|
654
|
-
assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){
|
654
|
+
assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
|
655
655
|
end
|
656
656
|
|
657
657
|
should "allow calling methods with invalid arity" do
|
@@ -684,37 +684,73 @@ module MuchStub
|
|
684
684
|
end
|
685
685
|
|
686
686
|
class TestClass
|
687
|
-
def self.noargs
|
688
|
-
|
689
|
-
|
690
|
-
def self.
|
691
|
-
|
692
|
-
|
693
|
-
def
|
694
|
-
|
695
|
-
|
696
|
-
def minargs(a, b, *args)
|
697
|
-
|
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
|
698
716
|
end
|
699
717
|
|
700
718
|
module TestModule
|
701
|
-
def self.noargs
|
702
|
-
|
703
|
-
|
704
|
-
def self.
|
705
|
-
|
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
|
706
733
|
end
|
707
734
|
|
708
735
|
module TestMixin
|
709
|
-
def noargs
|
710
|
-
|
711
|
-
|
712
|
-
def
|
713
|
-
|
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
|
714
750
|
end
|
715
751
|
|
716
752
|
class DelegateClass
|
717
|
-
def self.
|
753
|
+
def self.respond_to_missing?(*args)
|
718
754
|
TestClass.respond_to?(*args) || super
|
719
755
|
end
|
720
756
|
|
@@ -726,7 +762,7 @@ module MuchStub
|
|
726
762
|
@delegate = TestClass.new
|
727
763
|
end
|
728
764
|
|
729
|
-
def
|
765
|
+
def respond_to_missing?(*args)
|
730
766
|
@delegate.respond_to?(*args) || super
|
731
767
|
end
|
732
768
|
|
data/test/unit/call_spy_tests.rb
CHANGED
@@ -75,7 +75,8 @@ class MuchStub::CallSpy
|
|
75
75
|
end
|
76
76
|
subject{ @spy }
|
77
77
|
|
78
|
-
should "return the given values instead of itself if that method is
|
78
|
+
should "return the given values instead of itself if that method is "\
|
79
|
+
"called" do
|
79
80
|
assert_false subject.get.set!("value1").any?
|
80
81
|
assert_true subject.get_called?
|
81
82
|
assert_equal ["value1"], subject.set_bang_called_with.args
|
@@ -87,7 +88,7 @@ class MuchStub::CallSpy
|
|
87
88
|
desc "when init with return value procs"
|
88
89
|
setup do
|
89
90
|
@result = Factory.boolean
|
90
|
-
@spy = @unit_class.new(any?: ->(
|
91
|
+
@spy = @unit_class.new(any?: ->(_call){ @result })
|
91
92
|
end
|
92
93
|
subject{ @spy }
|
93
94
|
|