Class: MotionSpec::Matcher::HaveItems

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/have_items.rb

Instance Method Summary collapse

Constructor Details

#initialize(number_of_items) ⇒ HaveItems

Returns a new instance of HaveItems.



5
6
7
# File 'lib/motion-spec/matcher/have_items.rb', line 5

def initialize(number_of_items)
  @number_of_items = number_of_items
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



20
21
22
23
24
25
26
# File 'lib/motion-spec/matcher/have_items.rb', line 20

def fail!(subject, negated)
  raise FailedExpectation.new(
    FailMessageRenderer.message_for_have_items(
      negated, subject, @number_of_items, subject.size, @key_type_name
    )
  )
end

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/motion-spec/matcher/have_items.rb', line 9

def matches?(value)
  value.size == @number_of_items
end