+get = require 'lodash/get'
+
 jasmine.addMatchers
 
   toHaveRendered: ->

      else
        pass = expected is actual
        hint = utils.matcherHint('.toEqual')
      failures.push(
        "test #{i} #{type} #{hint}: #{utils.printExpected(expected)}, received #{utils.printReceived(actual)}"
      ) unless pass

    testValue(i, 'from value', test.from, test.value()) for test, i in tests

    fn()

    for test, i in tests
      expected = if test.by? then (test.from + test.by) else test.to
      testValue(i, 'changed value', expected, test.value())

    if failures.length
      { pass: false, message: -> failures.join("\n") }

  toHaveChanged: (fn, tests) ->
    failures = []
    utils = @utils

    testValue = (i, test, type, expected) ->
      actual = get(test.object, test.property, test.value?())
      actual = parseFloat(actual) unless typeof actual is 'number'

      if test.precision
        utils.ensureNumbers(actual, expected, "test index #{i}")
        pass = Math.abs(expected - actual) < Math.pow(10, -test.precision) / 2
