Sha256: 6ac7c80056eca101ba98565e67bfadf315a1aaf59c91180e1a6260b57dc06318

Contents?: true

Size: 844 Bytes

Versions: 134

Compression:

Stored size: 844 Bytes

Contents

class EqualUtf16Matcher
  def initialize(expected)
    @expected = expected
  end

  def matches?(actual)
    @actual = actual
    @actual == @expected || @actual == expected_swapped
  end

  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

  def failure_message
    ["Expected #{@actual.pretty_inspect}",
     "to equal #{@expected.pretty_inspect} or #{expected_swapped.pretty_inspect}"]
  end

  def negative_failure_message
    ["Expected #{@actual.pretty_inspect}",
     "not to equal #{@expected.pretty_inspect} nor #{expected_swapped.pretty_inspect}"]
  end
end

class Object
  def equal_utf16(expected)
    EqualUtf16Matcher.new(expected)
  end
end

Version data entries

134 entries across 110 versions & 3 rubygems

Version Path
rhodes-2.0.3 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.2 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.2 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.rc2 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.rc2 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.rc1 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.rc1 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta11 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta11 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta10 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta10 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta9 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta9 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta8 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta8 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta7 res/generators/templates/spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta7 spec/framework_spec/app/mspec/matchers/equal_utf16.rb
rhodes-2.0.0.beta6 spec/framework_spec/app/mspec/matchers/equal_utf16.rb