模块: RSpec::Matchers::BuiltIn::CountExpectation 私有

包含于
Include, YieldControl
定义于
lib/rspec/matchers/built_in/count_expectation.rb

概述

此模块是私有 API 的一部分。 尽可能避免使用此模块,因为它可能会在将来被删除或更改。

实现 onceat_least 和其他计数约束的抽象类。

实例方法摘要 折叠

实例方法详情

#at_least(number) ⇒Object

指定方法应匹配的最小次数

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

指定方法应匹配的最大次数

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

指定方法应匹配给定次数。

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

指定方法应匹配一次。

10
11
12
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 10
def once
  exactly(1)
end

#thriceObject

指定方法应匹配三次。

22
23
24
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 22
def thrice
  exactly(3)
end

#timesObject

无操作。提供语法糖。

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

#twiceObject

指定方法应匹配两次。

16
17
18
# File 'lib/rspec/matchers/built_in/count_expectation.rb', line 16
def twice
  exactly(2)
end