Parent

Included Modules

Files

RSpec::Matchers::BeWithin

Attributes

delta[R]

Public Class Methods

new(delta) click to toggle source
# File lib/rspec/matchers/be_within.rb, line 8
def initialize(delta)
  @delta = delta
end

Public Instance Methods

description() click to toggle source
# File lib/rspec/matchers/be_within.rb, line 32
def description
  "be within #{delta} of #{expected}"
end
failure_message_for_should() click to toggle source
# File lib/rspec/matchers/be_within.rb, line 24
def failure_message_for_should
  "expected #{actual} to #{description}"
end
failure_message_for_should_not() click to toggle source
# File lib/rspec/matchers/be_within.rb, line 28
def failure_message_for_should_not
  "expected #{actual} not to #{description}"
end
matches?(actual) click to toggle source
# File lib/rspec/matchers/be_within.rb, line 12
def matches?(actual)
  unless defined?(@expected)
    raise ArgumentError.new("You must set an expected value using #of: be_within(#{delta}).of(expected_value)")
  end
  (super(actual) - expected).abs < delta
end
of(expected) click to toggle source
# File lib/rspec/matchers/be_within.rb, line 19
def of(expected)
  @expected = expected
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.