This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -732,12 +732,14 @@ def initialize(procs_to_invoke)
732
732
@procs_to_invoke = procs_to_invoke
733
733
end
734
734
735
- def call ( *_args_to_ignore , &_block )
736
- if @procs_to_invoke . size > 1
737
- @procs_to_invoke . shift . call
738
- else
739
- @procs_to_invoke . first . call
740
- end
735
+ def call ( *args , &block )
736
+ proc = if @procs_to_invoke . size > 1
737
+ @procs_to_invoke . shift
738
+ else
739
+ @procs_to_invoke . first
740
+ end
741
+
742
+ proc . call ( *args , &block )
741
743
end
742
744
end
743
745
Original file line number Diff line number Diff line change @@ -28,6 +28,18 @@ module Mocks
28
28
. to raise_error ( ArgumentError , "Arguments to `and_invoke` must be callable." )
29
29
end
30
30
end
31
+
32
+ context 'when calling passed callables' do
33
+ let ( :dbl ) { double }
34
+
35
+ it 'passes the arguments into the callable' do
36
+ expect ( dbl ) . to receive ( :square_then_cube ) . and_invoke ( lambda { |i | i ** 2 } ,
37
+ lambda { |i | i ** 3 } )
38
+
39
+ expect ( dbl . square_then_cube ( 2 ) ) . to eq 4
40
+ expect ( dbl . square_then_cube ( 2 ) ) . to eq 8
41
+ end
42
+ end
31
43
end
32
44
end
33
45
end
You can’t perform that action at this time.
0 commit comments