Sha256: 02dc2f13bcf7801a3b24131af4000948bfa7de86b597f002f1f78ccc1464bc3a

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

gem 'minitest', '>= 4.7'
require 'bogus'

module MiniTest::Assertions
  def assert_received(subject, method, args, message = nil)
    with_bogus_matcher_for(subject, method, args) do |matcher, result|
      assert(result, message || matcher.failure_message_for_should)
    end
  end

  def refute_received(subject, method, args, message = nil)
    with_bogus_matcher_for(subject, method, args) do |matcher, result|
      refute(result, message || matcher.failure_message_for_should_not)
    end
  end

  private

  def with_bogus_matcher_for(subject, method, args)
    matcher = Bogus.have_received.__send__(method, *args)
    result  = matcher.matches?(subject)
    yield matcher, result
  end
end

module Bogus::Minitest
  include Bogus::MockingDSL

  def before_setup
    super
    Bogus.clear
  end

  def after_teardown
    Bogus.ensure_all_expectations_satisfied!
    super
  end
end

# minitest 5 vs 4.7
if defined? Minitest::Test
  class Minitest::Test
    include Bogus::Minitest
  end
else
  class MiniTest::Unit::TestCase
    include Bogus::Minitest
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bogus-0.1.6 lib/bogus/minitest.rb
bogus-0.1.5 lib/bogus/minitest.rb
bogus-0.1.4 lib/bogus/minitest.rb