Class: Smartest::IncludeMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ IncludeMatcher

Returns a new instance of IncludeMatcher.



57
58
59
# File 'lib/smartest/matchers.rb', line 57

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject



68
69
70
# File 'lib/smartest/matchers.rb', line 68

def failure_message
  "expected #{@actual.inspect} to include #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
# File 'lib/smartest/matchers.rb', line 61

def matches?(actual)
  @actual = actual
  actual.include?(@expected)
rescue NoMethodError
  false
end

#negated_failure_messageObject



72
73
74
# File 'lib/smartest/matchers.rb', line 72

def negated_failure_message
  "expected #{@actual.inspect} not to include #{@expected.inspect}"
end