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?, #expects_call_stack_jump?, #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

#initializeYieldControl

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



96
97
98
# File 'lib/rspec/matchers/built_in/yield.rb', line 96

def initialize
  at_least(:once)
end

Instance Method Details

#at_least(number) ⇒ Object

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



137
138
139
140
# File 'lib/rspec/matchers/built_in/yield.rb', line 137

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

#at_most(number) ⇒ Object

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



130
131
132
133
# File 'lib/rspec/matchers/built_in/yield.rb', line 130

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

#exactly(number) ⇒ Object

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



123
124
125
126
# File 'lib/rspec/matchers/built_in/yield.rb', line 123

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

#failure_messageString

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.



163
164
165
# File 'lib/rspec/matchers/built_in/yield.rb', line 163

def failure_message
  'expected given block to yield control' + failure_reason
end

#failure_message_when_negatedString

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.



169
170
171
# File 'lib/rspec/matchers/built_in/yield.rb', line 169

def failure_message_when_negated
  'expected given block not to yield control' + failure_reason
end

#onceObject

Specifies that the method is expected to yield once.



102
103
104
105
# File 'lib/rspec/matchers/built_in/yield.rb', line 102

def once
  exactly(1)
  self
end

#thriceObject

Specifies that the method is expected to yield thrice.



116
117
118
119
# File 'lib/rspec/matchers/built_in/yield.rb', line 116

def thrice
  exactly(3)
  self
end

#timesObject

No-op. Provides syntactic sugar.



144
145
146
# File 'lib/rspec/matchers/built_in/yield.rb', line 144

def times
  self
end

#twiceObject

Specifies that the method is expected to yield twice.



109
110
111
112
# File 'lib/rspec/matchers/built_in/yield.rb', line 109

def twice
  exactly(2)
  self
end