Class: Minitest::MustWonted::Matcher::Magick

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/mustwonted/matcher/magick.rb

Overview

The Magick ‘be_smth` matcher

Instance Method Summary collapse

Constructor Details

#initialize(name, args) ⇒ Magick

Returns a new instance of Magick.



6
7
8
9
10
# File 'lib/minitest/mustwonted/matcher/magick.rb', line 6

def initialize(name, args)
  @name = name.slice(3, name.size)
  @name+= '?' if name[name.size - 1] != '?'
  @args = args
end

Instance Method Details

#match?(subject, wont) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
# File 'lib/minitest/mustwonted/matcher/magick.rb', line 12

def match?(subject, wont)
  @name = 'is_a?' if @name == 'a?' || @name == 'an?'
  match = subject.send @name, *@args

  if wont ? match : !match
    raise Minitest::Assertion, "Expected #{subject.inspect} ##{
      @name} to return: #{ wont ? "false" : "true"
    }\nbut instead have: #{match.inspect}"
  end
end