Sha256: 29c760df94ac0e9cf7d72f2fc6399e2a38ff58c1532df53491b5a9c18feecf65

Contents?: true

Size: 822 Bytes

Versions: 6

Compression:

Stored size: 822 Bytes

Contents

class g:MatchTester

  defm test_from_env(matcher_name, expected)
    env = g:speckle_env
    matchers = env.matchers
    match_item = matchers.get_match_item(matcher_name)
    negate = match_item.negate
    matcher = match_item.matcher
    actual = env.actual

    self.test(matcher, negate, expected, actual)
  end

  def test(matcher, negate, expected, actual)
    result = matcher.match(expected, actual)
    g:speckle_env.assertions += 1
    if negate
      if result
        message = matcher.failure_message_for_mismatch(expected, actual)
        message = "AssertionError: #{message}"
        throw message
      end
    else
      unless result
        message = matcher.failure_message_for_match(expected, actual)
        message = "AssertionError: #{message}"
        throw message
      end
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
speckle-0.2.0 lib/matchers/match_tester.riml
speckle-0.1.31 lib/matchers/match_tester.riml
speckle-0.1.30 lib/matchers/match_tester.riml
speckle-0.1.29 lib/matchers/match_tester.riml
speckle-0.1.28 lib/matchers/match_tester.riml
speckle-0.1.27 lib/matchers/match_tester.riml