Class: Mustard::BeMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(subject, method, *args) ⇒ BeMatcher

Returns a new instance of BeMatcher.



3
4
5
6
7
# File 'lib/mustard/matchers/be_matcher.rb', line 3

def initialize(subject, method, *args)
  @subject = subject
  @method = method
  @args = args
end

Instance Method Details

#failure_messageObject



13
14
15
# File 'lib/mustard/matchers/be_matcher.rb', line 13

def failure_message
  "expected #{@subject.inspect} to be #{message_action}"
end

#match?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/mustard/matchers/be_matcher.rb', line 9

def match?
  @subject.send(@method, *@args)
end

#message_actionObject



21
22
23
24
25
# File 'lib/mustard/matchers/be_matcher.rb', line 21

def message_action
  message_action = @method.to_s.sub(/\?$/, "")
  message_action += " " + @args.map(&:inspect).join(" and ") unless @args.empty?
  message_action
end

#negative_failure_messageObject



17
18
19
# File 'lib/mustard/matchers/be_matcher.rb', line 17

def negative_failure_message
  "expected #{@subject.inspect} to not be #{message_action}"
end