Class: Mustard::Must

Inherits:
Object
  • Object
show all
Defined in:
lib/mustard/must.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, negate = false) ⇒ Must

Returns a new instance of Must.



17
18
19
20
# File 'lib/mustard/must.rb', line 17

def initialize(subject, negate = false)
  @subject = subject
  @negate = negate
end

Class Method Details

.matcher(name, *other_names, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mustard/must.rb', line 3

def self.matcher(name, *other_names, &block)
  if block
    matcher_class = DefaultMatcher.subclass_for(name, block)
  else
    matcher_class = other_names.pop
  end
  define_method(name) do |*args|
    _assert matcher_class.new(@subject, *args)
  end
  other_names.each do |other_name|
    alias_method other_name, name
  end
end