Class: EqualUtf16Matcher
Instance Method Summary collapse
- #expected_swapped ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ EqualUtf16Matcher
constructor
A new instance of EqualUtf16Matcher.
- #matches?(actual) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected) ⇒ EqualUtf16Matcher
Returns a new instance of EqualUtf16Matcher.
2 3 4 |
# File 'lib/mspec/matchers/equal_utf16.rb', line 2 def initialize(expected) @expected = expected end |
Instance Method Details
#expected_swapped ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mspec/matchers/equal_utf16.rb', line 11 def expected_swapped if @expected.respond_to?(:to_str) @expected_swapped ||= @expected.to_str.gsub(/(.)(.)/, '\2\1') else @expected_swapped ||= @expected.collect { |s| s.to_str.gsub(/(.)(.)/, '\2\1') } end end |
#failure_message ⇒ Object
19 20 21 22 |
# File 'lib/mspec/matchers/equal_utf16.rb', line 19 def ["Expected #{@actual.pretty_inspect}", "to equal #{@expected.pretty_inspect} or #{expected_swapped.pretty_inspect}"] end |
#matches?(actual) ⇒ Boolean
6 7 8 9 |
# File 'lib/mspec/matchers/equal_utf16.rb', line 6 def matches?(actual) @actual = actual @actual == @expected || @actual == expected_swapped end |
#negative_failure_message ⇒ Object
24 25 26 27 |
# File 'lib/mspec/matchers/equal_utf16.rb', line 24 def ["Expected #{@actual.pretty_inspect}", "not to equal #{@expected.pretty_inspect} nor #{expected_swapped.pretty_inspect}"] end |