Skip to content

Commit

Permalink
Spy::Instance#instead - initial test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jbodah committed Jun 6, 2016
1 parent 2d7369e commit 0d01c1b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/instead_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'test_helper'

class InsteadTest < Minitest::Spec
describe 'Spy::Instance#instead' do
after do
Spy.restore(:all)
end

it 'will run the instead block and not the original call' do
o = Object.new
o.instance_eval do
def incr; @total ||= 0; @total += 1; end
def total; @total; end
def total=(n); @total = n; end
end

Spy.on(o, :incr).instead do |mc|
mc.receiver.total += 2
end

o.incr

assert_equal 2, o.total
end

it 'will return the value returned by the block' do
fail
end

it 'plays nicely with Spy::Instance#when' do
fail
end
end
end

0 comments on commit 0d01c1b

Please sign in to comment.