Module: RSpec::Matchers::BuiltIn::CountExpectation Private

Included in:
Include, YieldControl
Defined in:
lib/rspec/matchers/built_in/count_expectation.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Asbtract class to implement once, at_least and other count constraints.

Instance Method Summary collapse

Instance Method Details

#at_least(number) ⇒ Object

Specifies the minimum number of times the method is expected to match


42
43
44
45
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 42

def at_least(number)
  set_expected_count(:>=, number)
  self
end

#at_most(number) ⇒ Object

Specifies the maximum number of times the method is expected to match


35
36
37
38
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 35

def at_most(number)
  set_expected_count(:<=, number)
  self
end

#exactly(number) ⇒ Object

Specifies that the method is expected to match the given number of times.


28
29
30
31
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 28

def exactly(number)
  set_expected_count(:==, number)
  self
end

#onceObject

Specifies that the method is expected to match once.


10
11
12
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 10

def once
  exactly(1)
end

#thriceObject

Specifies that the method is expected to match thrice.


22
23
24
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 22

def thrice
  exactly(3)
end

#timesObject

No-op. Provides syntactic sugar.


49
50
51
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 49

def times
  self
end

#twiceObject

Specifies that the method is expected to match twice.


16
17
18
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 16

def twice
  exactly(2)
end