Skip to content

Commit

Permalink
track stubbed calls in call history
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Bodah committed Apr 18, 2019
1 parent 3e6b701 commit 567ce2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/spy/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def apply(method_call)
runner =
if @internal[:instead]
proc do
@call_history << method_call
result = @internal[:instead].call(method_call)
end
else
Expand Down
9 changes: 9 additions & 0 deletions test/instead_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,14 @@ def name; 'josh'; end
o.value = 1
assert_equal 'lauren', o.name
end

it 'records the call in call history' do
o = Object.new
spy = Spy.on(o, :to_s).instead { 'moo' }

o.to_s

assert spy.called?
end
end
end

0 comments on commit 567ce2d

Please sign in to comment.