Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jbodah committed May 28, 2015
1 parent 70b00d4 commit 5b85ae7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/call_history_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'test_helper'

class CallHistoryTest < Minitest::Spec
after do
Spy.restore(:all)
end

describe 'Spy::Instance#call_history' do
it 'is empty when no calls have been made' do
arr = Array.new
Expand Down Expand Up @@ -77,5 +81,25 @@ def perform
obj.perform
assert_equal :perform, spy.call_history[0].name
end

it 'deep copies the arguments' do
arr = [1, 2, 3]
obj = Object.new
obj.instance_eval { def self.accept(arg); end }
spy = Spy.on(obj, :accept)
obj.accept(arr)
arr.shift
assert_equal [1, 2, 3], spy.call_history[0].args[0]
end

it 'deep copies the result' do
arr = [1, 2, 3]
obj = Object.new
obj.instance_eval { def self.accept(arg); arg; end }
spy = Spy.on(obj, :accept)
obj.accept(arr)
arr.shift
assert_equal [1, 2, 3], spy.call_history[0].result
end
end
end

0 comments on commit 5b85ae7

Please sign in to comment.