class MotionSpec::Matcher::BeWithin
Constants
- INVALID_MATCH_ERROR
Public Class Methods
new(range)
click to toggle source
# File lib/motion-spec/matcher/be_within.rb, line 6 def initialize(range) @range = range end
Public Instance Methods
fail!(subject, negated)
click to toggle source
# File lib/motion-spec/matcher/be_within.rb, line 20 def fail!(subject, negated) fail FailedExpectation.new( FailMessageRenderer.message_for_be_within( negated, subject, @range, @center_value ) ) end
matches?(subject)
click to toggle source
# File lib/motion-spec/matcher/be_within.rb, line 15 def matches?(subject) fail InvalidMatcher.new(INVALID_MATCH_ERROR) unless @center_value (subject - @center_value).abs <= @range end
of(center_value)
click to toggle source
# File lib/motion-spec/matcher/be_within.rb, line 10 def of(center_value) @center_value = center_value self end