Sha256: ac05a98e4f5ca0e911d20aa2f15f7c97b51ea787e0e2775ec049801277020f33

Contents?: true

Size: 860 Bytes

Versions: 11

Compression:

Stored size: 860 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

    tester = new g:MatchTester()
    tester.test(matcher, negate, a:expected, actual)
  end

  defm 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

11 entries across 11 versions & 1 rubygems

Version Path
speckle-0.1.26 lib/matchers/match_tester.riml
speckle-0.1.25 lib/matchers/match_tester.riml
speckle-0.1.24 lib/matchers/match_tester.riml
speckle-0.1.23 lib/matchers/match_tester.riml
speckle-0.1.22 lib/matchers/match_tester.riml
speckle-0.1.21 lib/matchers/match_tester.riml
speckle-0.1.20 lib/matchers/match_tester.riml
speckle-0.1.19 lib/matchers/match_tester.riml
speckle-0.1.18 lib/matchers/match_tester.riml
speckle-0.1.17 lib/matchers/match_tester.riml
speckle-0.1.16 lib/matchers/match_tester.riml