Sha256: 410c2b84ae6611edcf145f42e981644683a881efadd0a6559cb24bb206ef1114
Contents?: true
Size: 809 Bytes
Versions: 2
Compression:
Stored size: 809 Bytes
Contents
module Spec module Matchers # :call-seq: # should be_close(expected, delta) # should_not be_close(expected, delta) # # Passes if actual == expected +/- delta # # == Example # # result.should be_close(3.0, 0.5) def be_close(expected, delta) Matcher.new :be_close, expected, delta do |expected, delta| match do |actual| (actual - expected).abs < delta end failure_message_for_should do |actual| "expected #{expected} +/- (< #{delta}), got #{actual}" end failure_message_for_should_not do |actual| "expected #{expected} +/- (< #{delta}), got #{actual}" end description do "be close to #{expected} (within +- #{delta})" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-1.2.3 | lib/spec/matchers/be_close.rb |
rspec-1.2.4 | lib/spec/matchers/be_close.rb |