Sha256: f510af5d4a05c3c41406ba07cdebdbca113459a8e5d76f27415f1aa167ec9b6f

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module MiniTest
  module Assertions
    def assert_must(subject, matcher, msg = nil)
      msg = message(msg) do
        if matcher.respond_to? :failure_message
          "Expected #{matcher.failure_message}".squeeze(" ")
        else
          "Expected #{subject.inspect} to #{matcher.description}".squeeze(" ")
        end
      end

      assert matcher.matches?(subject), msg
    end

    def assert_wont(subject, matcher, msg = nil)
      msg = message(msg) do
        if matcher.respond_to? :negative_failure_message
          "Expected #{matcher.negative_failure_message}".squeeze(" ")
        else
          "Expected not to #{matcher.description}".squeeze(" ")
        end
      end

      refute matcher.matches?(subject), msg
    end
  end

  module Expectations
    infect_an_assertion :assert_must, :must, :reverse
    infect_an_assertion :assert_wont, :wont, :reverse
  end
end

class MiniTest::Spec
  def must(*args, &block)
    subject.must(*args, &block)
  end

  def wont(*args, &block)
    subject.wont(*args, &block)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid-minitest-0.1.1 lib/minitest/matchers.rb
mongoid-minitest-0.1.0 lib/minitest/matchers.rb
mongoid-minitest-0.0.3.1 lib/minitest/matchers.rb
mongoid-minitest-0.0.3 lib/minitest/matchers.rb
mongoid-minitest-0.0.2 lib/minitest/matchers.rb