Class: Matchers::EndWith
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- Matchers::EndWith
- Defined in:
- lib/pidgin_spec/matchers/end_with.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected) ⇒ EndWith
constructor
A new instance of EndWith.
- #matches?(value) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ EndWith
Returns a new instance of EndWith.
3 4 5 |
# File 'lib/pidgin_spec/matchers/end_with.rb', line 3 def initialize(expected) @expected = expected.length == 1 ? expected.first : expected end |
Instance Method Details
#failure_message ⇒ Object
26 27 28 |
# File 'lib/pidgin_spec/matchers/end_with.rb', line 26 def "You bin dey expect make #{@value} end with #{@expected}, but e no con end with am" end |
#failure_message_when_negated ⇒ Object
22 23 24 |
# File 'lib/pidgin_spec/matchers/end_with.rb', line 22 def "You bin dey expect say #{@value} no go end with #{@expected}, but e con end with am" end |
#matches?(value) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pidgin_spec/matchers/end_with.rb', line 7 def matches?(value) @value = value if @expected.is_a?(String) || @expected.is_a?(Array) @value[-@expected.length, @expected.length] == @expected else @value.last == @expected end # if value.is_a?(String) && @expected.is_a?(String) # @value[-@expected[0].length, @expected[0].length] == @expected[0] # elsif value.is_a? Array # array_len = @expected.length # @value.last(array_len) == @expected # end end |