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.



42
43
44
# File 'lib/smartest/matchers.rb', line 42

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject



53
54
55
# File 'lib/smartest/matchers.rb', line 53

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/smartest/matchers.rb', line 46

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

#negated_failure_messageObject



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

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