Sha256: fd0ca24b4f2b7af77e52f54772aa1693b829635bdda0ff68dd0b1a215e6ccff1

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require 'test_helper'

class TestApi < MiniTest::Unit::TestCase
  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

2 entries across 2 versions & 1 rubygems

Version Path
spy-0.4.1 test/integration/test_api.rb
spy-0.4.0 test/integration/test_api.rb