Parent

Included Modules

Class Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::MatchArray

Public Class Methods

new(expected) click to toggle source
   # File lib/rspec/matchers/built_in/match_array.rb, line 7
7:         def initialize(expected)
8:           @expected = expected
9:         end

Public Instance Methods

description() click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 30
30:         def description
31:           "contain exactly #{_pretty_print(@expected)}"
32:         end
failure_message_for_should() click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 18
18:         def failure_message_for_should
19:           message =  "expected collection contained:  #{safe_sort(@expected).inspect}\n"
20:           message += "actual collection contained:    #{safe_sort(@actual).inspect}\n"
21:           message += "the missing elements were:      #{safe_sort(@missing_items).inspect}\n" unless @missing_items.empty?
22:           message += "the extra elements were:        #{safe_sort(@extra_items).inspect}\n"   unless @extra_items.empty?
23:           message
24:         end
failure_message_for_should_not() click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 26
26:         def failure_message_for_should_not
27:           "Matcher does not support should_not"
28:         end
matches?(actual) click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 11
11:         def matches?(actual)
12:           @actual = actual        
13:           @extra_items = difference_between_arrays(@actual, @expected)
14:           @missing_items = difference_between_arrays(@expected, @actual)
15:           @extra_items.empty? & @missing_items.empty?
16:         end

Private Instance Methods

difference_between_arrays(array_1, array_2) click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 40
40:         def difference_between_arrays(array_1, array_2)
41:           difference = array_1.dup
42:           array_2.each do |element|
43:             if index = difference.index(element)
44:               difference.delete_at(index)
45:             end
46:           end
47:           difference
48:         end
safe_sort(array) click to toggle source
    # File lib/rspec/matchers/built_in/match_array.rb, line 36
36:         def safe_sort(array)
37:           array.sort rescue array
38:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.