Sha256: 4c504a4069cf3063e0aba4c74e9f98426a490cb6453ad127dca34c997b727acf

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

RSpec::Matchers.define :be_equivalent_eps_to do |expected|
  match do |actual|
    e = sub_time_and_version(expected)
    a = sub_time_and_version(actual)

    windows_pattern = /mswin|msys|mingw|cygwin|bccwin|wince|emc/
    if RbConfig::CONFIG["host_os"].match?(windows_pattern)
      Vectory.ui.debug("Using `TextMatcher`.")

      Vectory::TextMatcher.new(allowed_changed_lines: 60,
                               allowed_changed_words_in_line: 5).match?(e, a)
    else
      Vectory.ui.debug("Using a default matcher.")

      values_match?(e, a)
    end
  end

  def sub_time_and_version(str)
    str.sub(/%%CreationDate:(.+)$/, "%%CreationDate:")
      .sub(/%%Creator: cairo(.+)$/, "%%Creator: cairo")
  end

  diffable
end

RSpec::Matchers.define :be_equivalent_svg_to do |expected|
  match do |actual|
    e = sub_unimportant(expected)
    a = sub_unimportant(actual)
    values_match?(e, a)
  end

  def sub_unimportant(str)
    str.sub(/sodipodi:docname=(.+)$/, "sodipodi:docname=")
  end

  diffable
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vectory-0.3.0 spec/support/matchers.rb
vectory-0.2.0 spec/support/matchers.rb