Class: RSpec::Matchers::BuiltIn::Include Private
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::Include
- Includes:
- CountExpectation
- Defined in:
- lib/rspec/matchers/built_in/include.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 include
.
Not intended to be instantiated directly.
Constant Summary
Constants inherited from BaseMatcher
Instance Method Summary collapse
- #description ⇒ String private
- #diffable? ⇒ Boolean private
- #does_not_match?(actual) ⇒ Boolean private
- #expected ⇒ Array, Hash private
- #failure_message ⇒ String private
- #failure_message_when_negated ⇒ String private
-
#initialize(*expecteds) ⇒ Include
constructor
private
A new instance of Include.
- #matches?(actual) ⇒ Boolean private
Methods included from CountExpectation
#at_least, #at_most, #exactly, #once, #thrice, #times, #twice
Methods inherited from BaseMatcher
#expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?
Methods included from Composable
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
Constructor Details
#initialize(*expecteds) ⇒ Include
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 Include.
15 16 17 18 |
# File 'lib/rspec/matchers/built_in/include.rb', line 15 def initialize(*expecteds) raise(ArgumentError, 'include() is not supported, please supply an argument') if expecteds.empty? @expecteds = expecteds 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.
44 45 46 |
# File 'lib/rspec/matchers/built_in/include.rb', line 44 def description improve_hash_formatting("include#{readable_list_of(expecteds)}#{count_expectation_description}") end |
#diffable? ⇒ 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.
62 63 64 |
# File 'lib/rspec/matchers/built_in/include.rb', line 62 def diffable? !diff_would_wrongly_highlight_matched_item? end |
#does_not_match?(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.
33 34 35 36 37 38 39 40 |
# File 'lib/rspec/matchers/built_in/include.rb', line 33 def does_not_match?(actual) check_actual?(actual) && if check_expected_count? !expected_count_matches?(count_inclusions) else perform_match { |v| !v } end end |
#expected ⇒ Array, Hash
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.
68 69 70 71 72 73 74 |
# File 'lib/rspec/matchers/built_in/include.rb', line 68 def expected if expecteds.one? && Hash === expecteds.first expecteds.first else expecteds end 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.
50 51 52 |
# File 'lib/rspec/matchers/built_in/include.rb', line 50 def ("to") { super } end |
#failure_message_when_negated ⇒ 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.
56 57 58 |
# File 'lib/rspec/matchers/built_in/include.rb', line 56 def ("not to") { super } 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.
22 23 24 25 26 27 28 29 |
# File 'lib/rspec/matchers/built_in/include.rb', line 22 def matches?(actual) check_actual?(actual) && if check_expected_count? expected_count_matches?(count_inclusions) else perform_match { |v| v } end end |