Class: RSpec::Matchers::BuiltIn::MatchArray
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::MatchArray
- Defined in:
- lib/rspec/matchers/built_in/match_array.rb
Constant Summary
Constant Summary
Constants inherited from BaseMatcher
Instance Attribute Summary
Attributes inherited from BaseMatcher
#actual, #expected, #rescued_exception
Instance Method Summary (collapse)
- - (Object) description
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
- - (Object) match(expected, actual)
Methods inherited from BaseMatcher
#==, #diffable?, #initialize, #match_unless_raises, #matches?
Methods included from Pretty
#_pretty_print, #expected_to_sentence, #name, #name_to_sentence, #split_words, #to_sentence, #to_word, #underscore
Constructor Details
This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher
Instance Method Details
- (Object) description
29 30 31 |
# File 'lib/rspec/matchers/built_in/match_array.rb', line 29 def description "contain exactly #{_pretty_print(expected)}" end |
- (Object) failure_message_for_should
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec/matchers/built_in/match_array.rb', line 12 def if actual.respond_to? :to_ary = "expected collection contained: #{safe_sort(expected).inspect}\n" += "actual collection contained: #{safe_sort(actual).inspect}\n" += "the missing elements were: #{safe_sort(@missing_items).inspect}\n" unless @missing_items.empty? += "the extra elements were: #{safe_sort(@extra_items).inspect}\n" unless @extra_items.empty? else = "expected an array, actual collection was #{actual.inspect}" end end |
- (Object) failure_message_for_should_not
25 26 27 |
# File 'lib/rspec/matchers/built_in/match_array.rb', line 25 def "Matcher does not support should_not" end |
- (Object) match(expected, actual)
5 6 7 8 9 10 |
# File 'lib/rspec/matchers/built_in/match_array.rb', line 5 def match(expected, actual) return false unless actual.respond_to? :to_ary @extra_items = difference_between_arrays(actual, expected) @missing_items = difference_between_arrays(expected, actual) @extra_items.empty? & @missing_items.empty? end |