Class/Module Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::YieldControl

@api private Provides the implementation for `yield_control`. Not intended to be instantiated directly.

Public Class Methods

new() click to toggle source
# File lib/rspec/matchers/built_in/yield.rb, line 82
def initialize
  @expectation_type = nil
  @expected_yields_count = nil
end

Public Instance Methods

at_least(number) click to toggle source

@api public Specifies the minimum number of times the method is expected to yield

# File lib/rspec/matchers/built_in/yield.rb, line 117
def at_least(number)
  set_expected_yields_count(:>=, number)
  self
end
at_most(number) click to toggle source

@api public Specifies the maximum number of times the method is expected to yield

# File lib/rspec/matchers/built_in/yield.rb, line 110
def at_most(number)
  set_expected_yields_count(:<=, number)
  self
end
does_not_match?(block) click to toggle source

@private

# File lib/rspec/matchers/built_in/yield.rb, line 141
def does_not_match?(block)
  !matches?(block) && @probe.has_block?
end
exactly(number) click to toggle source

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

# File lib/rspec/matchers/built_in/yield.rb, line 103
def exactly(number)
  set_expected_yields_count(:==, number)
  self
end
failure_message() click to toggle source

@api private @return [String]

# File lib/rspec/matchers/built_in/yield.rb, line 147
def failure_message
  'expected given block to yield control' + failure_reason
end
failure_message_when_negated() click to toggle source

@api private @return [String]

# 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
matches?(block) click to toggle source

@private

# File lib/rspec/matchers/built_in/yield.rb, line 129
def matches?(block)
  @probe = YieldProbe.probe(block)
  return false unless @probe.has_block?

  if @expectation_type
    @probe.num_yields.__send__(@expectation_type, @expected_yields_count)
  else
    @probe.yielded_once?(:yield_control)
  end
end
once() click to toggle source

@api public Specifies that the method is expected to yield once.

# File lib/rspec/matchers/built_in/yield.rb, line 89
def once
  exactly(1)
  self
end
supports_block_expectations?() click to toggle source

@private

# File lib/rspec/matchers/built_in/yield.rb, line 158
def supports_block_expectations?
  true
end
times() click to toggle source

@api public No-op. Provides syntactic sugar.

# File lib/rspec/matchers/built_in/yield.rb, line 124
def times
  self
end
twice() click to toggle source

@api public Specifies that the method is expected to yield once.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.