Sha256: 4eadcc2be07d57cc248c6f16874de08063143b40c8847816389a69f676e182ef

Contents?: true

Size: 670 Bytes

Versions: 4

Compression:

Stored size: 670 Bytes

Contents

require 'test_helper'

class TestAnyInstanceOf < Minitest::Test
  class Foo
    def bar
      "foobar"
    end
  end

  class Bar < Foo
    def bar
      super
    end
  end

  def teardown
    Spy::Agency.instance.dissolve!
  end

  def test_it_overides_all_methods
    assert_equal Foo.new.bar, "foobar"
    spy = Spy.on_instance_method(Foo, bar: "timshel")
    assert_equal spy, Spy::Subroutine.get(Foo, :bar, false)
    assert_equal "timshel", Foo.new.bar
    assert_equal "timshel", Foo.new.bar
    assert_equal "timshel", Bar.new.bar
    assert_equal 3, spy.calls.size

    spy = Spy.off_instance_method(Foo, :bar)
    assert_equal Foo.new.bar, "foobar"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spy-1.0.0 test/integration/test_instance_method.rb
spy-0.4.5 test/integration/test_instance_method.rb
spy-0.4.3 test/integration/test_instance_method.rb
spy-0.4.2 test/integration/test_instance_method.rb