Class: RSpec::Matchers::BuiltIn::YieldControl Private

Inherits:
BaseMatcher
  • Object
show all
Defined in:
lib/rspec/matchers/built_in/yield.rb

Overview

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

Provides the implementation for yield_control. Not intended to be instantiated directly.

Constant Summary

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

Instance Method Summary (collapse)

Methods inherited from BaseMatcher

#description, #diffable?, #match_unless_raises

Methods included from Composable

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

Methods included from Pretty

#name, split_words, #to_sentence, #to_word

Constructor Details

- (YieldControl) initialize

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

Returns a new instance of YieldControl

82
83
84
85
# File 'lib/rspec/matchers/built_in/yield.rb', line 82
def initialize
  @expectation_type = nil
  @expected_yields_count = nil
end

Instance Method Details

- (Object) at_least(number)

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

117
118
119
120
# File 'lib/rspec/matchers/built_in/yield.rb', line 117
def at_least(number)
  set_expected_yields_count(:>=, number)
  self
end

- (Object) at_most(number)

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

110
111
112
113
# File 'lib/rspec/matchers/built_in/yield.rb', line 110
def at_most(number)
  set_expected_yields_count(:<=, number)
  self
end

- (Object) exactly(number)

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

103
104
105
106
# File 'lib/rspec/matchers/built_in/yield.rb', line 103
def exactly(number)
  set_expected_yields_count(:==, number)
  self
end

- (String) failure_message

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

Returns:

  • (String)
147
148
149
# File 'lib/rspec/matchers/built_in/yield.rb', line 147
def failure_message
  'expected given block to yield control' + failure_reason
end

- (String) failure_message_when_negated

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

Returns:

  • (String)
153
154
155
# File 'lib/rspec/matchers/built_in/yield.rb', line 153
def failure_message_when_negated
  'expected given block not to yield control' + failure_reason
end

- (Object) once

Specifies that the method is expected to yield once.

89
90
91
92
# File 'lib/rspec/matchers/built_in/yield.rb', line 89
def once
  exactly(1)
  self
end

- (Object) times

No-op. Provides syntactic sugar.

124
125
126
# File 'lib/rspec/matchers/built_in/yield.rb', line 124
def times
  self
end

- (Object) twice

Specifies that the method is expected to yield once.

96
97
98
99
# File 'lib/rspec/matchers/built_in/yield.rb', line 96
def twice
  exactly(2)
  self
end