Class: FlexMock::AtLeastCountValidator

Inherits:
CountValidator show all
Defined in:
lib/flexmock/validators.rb

Overview

Validator for call counts greater than or equal to a limit.

Instance Method Summary collapse

Methods inherited from CountValidator

#initialize, #validate_count

Methods included from SpyDescribers

#describe_spy_expectation, #describe_spy_negative_expectation, #spy_description

Constructor Details

This class inherits a constructor from FlexMock::CountValidator

Instance Method Details

#describeObject

Human readable description of the validator.



99
100
101
102
103
104
105
# File 'lib/flexmock/validators.rb', line 99

def describe
  if @limit == 0
    ".zero_or_more_times"
  else
    ".at_least#{super}"
  end
end

#describe_limitObject



115
116
117
# File 'lib/flexmock/validators.rb', line 115

def describe_limit
  "At least #{@limit}"
end

#eligible?(n) ⇒ Boolean

If the expectation has been called n times, is it still eligible to be called again? Since this validator only establishes a lower limit, not an upper limit, then the answer is always true.

Returns:

  • (Boolean)


111
112
113
# File 'lib/flexmock/validators.rb', line 111

def eligible?(n)
  true
end

#validate(n) ⇒ Object

Validate the method expectation was called no more than n times.



94
95
96
# File 'lib/flexmock/validators.rb', line 94

def validate(n)
  validate_count(n) { n >= @limit }
end