class RSpec::Matchers::BuiltIn::YieldWithNoArgs
@api private Provides the implementation for `yield_with_no_args`. Not intended to be instantiated directly.
Public Instance Methods
does_not_match?(block)
click to toggle source
@private
# File lib/rspec/matchers/built_in/yield.rb, line 226 def does_not_match?(block) !matches?(block) && @probe.has_block? end
failure_message()
click to toggle source
@private
# File lib/rspec/matchers/built_in/yield.rb, line 231 def failure_message "expected given block to yield with no arguments, but #{positive_failure_reason}" end
failure_message_when_negated()
click to toggle source
@private
# File lib/rspec/matchers/built_in/yield.rb, line 236 def failure_message_when_negated "expected given block not to yield with no arguments, but #{negative_failure_reason}" end
matches?(block)
click to toggle source
@private
# File lib/rspec/matchers/built_in/yield.rb, line 219 def matches?(block) @probe = YieldProbe.probe(block) return false unless @probe.has_block? @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty? end
supports_block_expectations?()
click to toggle source
@private
# File lib/rspec/matchers/built_in/yield.rb, line 241 def supports_block_expectations? true end
Private Instance Methods
negative_failure_reason()
click to toggle source
# File lib/rspec/matchers/built_in/yield.rb, line 253 def negative_failure_reason return "was not a block" unless @probe.has_block? "did" end
positive_failure_reason()
click to toggle source
# File lib/rspec/matchers/built_in/yield.rb, line 247 def positive_failure_reason return "was not a block" unless @probe.has_block? return "did not yield" if @probe.num_yields.zero? "yielded with arguments: #{@probe.single_yield_args.inspect}" end