Skip to content

Commit

Permalink
add toBeApproximately
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Nov 21, 2014
1 parent 16827d4 commit f446af1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/helpers/matchers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,15 @@ beforeEach( ->
return { message: message, pass: pass }
}

toBeApproximately: ->
return {
compare: (actual, expected, tolerance) ->
pass = Math.abs(actual - expected) <= tolerance
return {
pass: pass
message: "#{actual} is #{if pass then '' else 'not'} approximately #{expected}"
}
}

jasmine.addMatchers(matchers)
)

0 comments on commit f446af1

Please sign in to comment.