Parent

Included Modules

Class Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::BeWithin

Attributes

delta[R]

Public Class Methods

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

Public Instance Methods

description() click to toggle source
    # File lib/rspec/matchers/built_in/be_within.rb, line 33
33:         def description
34:           "be within #{delta} of #{expected}"
35:         end
failure_message_for_should() click to toggle source
    # File lib/rspec/matchers/built_in/be_within.rb, line 25
25:         def failure_message_for_should
26:           "expected #{actual} to #{description}"
27:         end
failure_message_for_should_not() click to toggle source
    # File lib/rspec/matchers/built_in/be_within.rb, line 29
29:         def failure_message_for_should_not
30:           "expected #{actual} not to #{description}"
31:         end
matches?(actual) click to toggle source
    # File lib/rspec/matchers/built_in/be_within.rb, line 13
13:         def matches?(actual)
14:           unless defined?(@expected)
15:             raise ArgumentError.new("You must set an expected value using #of: be_within(#{delta}).of(expected_value)")
16:           end
17:           (super(actual) - expected).abs <= delta
18:         end
of(expected) click to toggle source
    # File lib/rspec/matchers/built_in/be_within.rb, line 20
20:         def of(expected)
21:           @expected = expected
22:           self
23:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.