Sha256: 41d6d45b3195ca3ac6c78da238fc13daf4a8ef7a81658e8413ab1290e3e54c98

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

require 'muack/test'

describe Muack::AnyInstanceOf do
  should 'mock any_instance_of' do
    klass = Class.new
    any_instance_of(klass){ |instance| mock(instance).say{ true } }
    obj = klass.new
    obj.say              .should.eq true
    obj.respond_to?(:say).should.eq true
    Muack.verify         .should.eq true
    obj.respond_to?(:say).should.eq false
  end

  should 'proxy any_instance_of' do
    klass = Class.new{ def f; true; end }
    any_instance_of(klass){ |instance| mock_proxy(instance).f }
    obj = klass.new
    obj.f.should.eq true
    Muack.verify.should.eq true
  end

  should 'proxy any_instance_of with a block' do
    klass = Class.new{ def f; 0; end }
    any_instance_of(klass){ |instance| mock_proxy(instance).f{ |i| i+1 } }
    obj = klass.new
    obj.f.should.eq 1
    Muack.verify.should.eq true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
muack-0.5.0 test/test_any_instance_of.rb