Class: RSpec::Matchers::BuiltIn::BeBetween Private
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::BeBetween
- Defined in:
- lib/rspec/matchers/built_in/be_between.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides the implementation for be_between
.
Not intended to be instantiated directly.
Constant Summary
Constants inherited from BaseMatcher
RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED
Instance Method Summary collapse
- #description ⇒ String private
-
#exclusive ⇒ Object
Makes the between comparison exclusive.
- #failure_message ⇒ String private
-
#inclusive ⇒ Object
Makes the between comparison inclusive.
-
#initialize(min, max) ⇒ BeBetween
constructor
private
A new instance of BeBetween.
- #matches?(actual) ⇒ Boolean private
Methods inherited from BaseMatcher
#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?
Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages
Methods included from Composable
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
Constructor Details
#initialize(min, max) ⇒ BeBetween
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BeBetween.
8 9 10 11 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 8 def initialize(min, max) @min, @max = min, max inclusive end |
Instance Method Details
#description ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 57 def description "be between #{description_of @min} and #{description_of @max} (#{@mode})" end |
#exclusive ⇒ Object
Makes the between comparison exclusive.
33 34 35 36 37 38 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 33 def exclusive @less_than_operator = :< @greater_than_operator = :> @mode = :exclusive self end |
#failure_message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 51 def "#{super}#{not_comparable_clause}" end |
#inclusive ⇒ Object
The matcher is inclusive by default; this simply provides a way to be more explicit about it.
Makes the between comparison inclusive.
21 22 23 24 25 26 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 21 def inclusive @less_than_operator = :<= @greater_than_operator = :>= @mode = :inclusive self end |
#matches?(actual) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 |
# File 'lib/rspec/matchers/built_in/be_between.rb', line 42 def matches?(actual) @actual = actual comparable? && compare rescue ArgumentError false end |