Sha256: b3f97d68a6e0b8fc35b4dfe702980862d6e4ffa413810f79e6fd5ca0d9071a9a

Contents?: true

Size: 807 Bytes

Versions: 9

Compression:

Stored size: 807 Bytes

Contents

require 'test_helper'

class TestApi < Minitest::Test
  include Spy::API

  def setup
    @pen = Pen.new
    Spy.on(@pen, :write)
  end

  def test_assert_received
    @pen.write(:hello)
    assert_received(@pen, :write)
  end

  def test_assert_received_with
    @pen.write(:world)
    assert_received_with(@pen, :write, :world)
    assert_received_with(@pen, :write) do |call|
      call.args == [:world]
    end
  end

  def test_have_received
    @pen.write(:foo)
    matcher = have_received(:write)
    assert matcher.matches?(@pen)
  end

  def test_have_received_with
    @pen.write(:bar)
    matcher = have_received(:write).with(:bar)
    assert matcher.matches?(@pen)

    matcher = have_received(:write).with do |call|
      call.args == [:bar]
    end
    assert matcher.matches?(@pen)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spy-1.0.5 test/integration/test_api.rb
spy-1.0.4 test/integration/test_api.rb
spy-1.0.3 test/integration/test_api.rb
spy-1.0.2 test/integration/test_api.rb
spy-1.0.1 test/integration/test_api.rb
spy-1.0.0 test/integration/test_api.rb
spy-0.4.5 test/integration/test_api.rb
spy-0.4.3 test/integration/test_api.rb
spy-0.4.2 test/integration/test_api.rb