Class: MotionSpec::Matcher::EndWith

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/end_with.rb

Instance Method Summary collapse

Constructor Details

#initialize(end_string) ⇒ EndWith

Returns a new instance of EndWith.



5
6
7
# File 'lib/motion-spec/matcher/end_with.rb', line 5

def initialize(end_string)
  @end_string = end_string
end

Instance Method Details

#fail!(subject, negated) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/motion-spec/matcher/end_with.rb', line 13

def fail!(subject, negated)
  fail FailedExpectation.new(
    FailMessageRenderer.message_for_end_with(
      negated, subject, @end_string
    )
  )
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/motion-spec/matcher/end_with.rb', line 9

def matches?(subject)
  subject[-@end_string.size..-1] == @end_string
end