Class: DiffMatcher::AllMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/diff_matcher/difference.rb

Instance Attribute Summary

Attributes inherited from Matcher

#expecteds

Instance Method Summary collapse

Methods inherited from Matcher

[], #diff, #expected_opts, #initialize, #|

Constructor Details

This class inherits a constructor from DiffMatcher::Matcher

Instance Method Details

#expected(e, actual) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/diff_matcher/difference.rb', line 51

def expected(e, actual)
  opts = expected_opts(e)
  size = opts[:size]
  case size
  when Fixnum
    min = size
    max = size
  when Range
    min = size.first
    max = size.last
  else
    min = opts[:min] || 0
    max = opts[:max] || 1_000_000 # MAXINT?
  end
  size = actual.size
  size = size > min ? (size < max ? size : max) : min
  [e]*size
end