Class: ArgumentSpecification::Matchers::EndWith

Inherits:
BaseMatcher
  • Object
show all
Defined in:
lib/argspec/matchers/end_with.rb

Instance Attribute Summary collapse

Attributes inherited from BaseMatcher

#actual, #block, #metadata

Instance Method Summary collapse

Methods inherited from BaseMatcher

#failure_message, #failure_message_when_negated, matcher_name

Constructor Details

#initialize(expected) ⇒ EndWith

Create a new matcher instance

Arguments:

expected: (String)

Example:

>> ArgumentSpecification::Matchers::EndWith.new("test")
=> #<ArgumentSpecification::Matchers::EndWith:0x00000000000000 @expected="test">


17
18
19
# File 'lib/argspec/matchers/end_with.rb', line 17

def initialize(expected)
  @expected = expected
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



6
7
8
# File 'lib/argspec/matchers/end_with.rb', line 6

def expected
  @expected
end

Instance Method Details

#matches?Boolean

Check if the actual object matches

Example:

>> matcher.matches?
=> true

Returns:

  • (Boolean)


27
28
29
# File 'lib/argspec/matchers/end_with.rb', line 27

def matches?
  @actual.end_with?(@expected)
end