Skip to content

Commit

Permalink
Merge pull request #61 from QWYNG/add-Instance#called
Browse files Browse the repository at this point in the history
add Spy::Instance.called? and test
  • Loading branch information
jbodah committed Jan 20, 2019
2 parents 416f5f9 + e3b6179 commit 908dfb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/spy/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def instead(&block)
self
end

def called?
@call_history.any?
end

private

def choose_strategy(blueprint)
Expand Down
13 changes: 13 additions & 0 deletions test/called_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require_relative 'test_helper'

class CalledTest < Minitest::Spec
describe 'Spy::Instance#called?' do
it 'works' do
obj = Object.new
spy = Spy.on(obj, :to_s)
assert_equal spy.called?, false
obj.to_s
assert_equal spy.called?, true
end
end
end

0 comments on commit 908dfb2

Please sign in to comment.