Class: Spec::Matchers::MatchArray
- Defined in:
- lib/spec/matchers/match_array.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected) ⇒ MatchArray
constructor
A new instance of MatchArray.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ MatchArray
Returns a new instance of MatchArray.
6 7 8 |
# File 'lib/spec/matchers/match_array.rb', line 6 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/spec/matchers/match_array.rb', line 29 def description "contain exactly #{_pretty_print(@expected)}" end |
#failure_message_for_should ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/spec/matchers/match_array.rb', line 17 def = "expected collection contained: #{@expected.sort.inspect}\n" += "actual collection contained: #{@actual.sort.inspect}\n" += "the missing elements were: #{@missing_items.sort.inspect}\n" unless @missing_items.empty? += "the extra elements were: #{@extra_items.sort.inspect}\n" unless @extra_items.empty? end |
#failure_message_for_should_not ⇒ Object
25 26 27 |
# File 'lib/spec/matchers/match_array.rb', line 25 def "Matcher does not support should_not" end |
#matches?(actual) ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/spec/matchers/match_array.rb', line 10 def matches?(actual) @actual = actual @extra_items = difference_between_arrays(@actual, @expected) @missing_items = difference_between_arrays(@expected, @actual) @extra_items.empty? & @missing_items.empty? end |