Class: RSpec::Matchers::BuiltIn::YieldWithNoArgs

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

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected, #rescued_exception

Instance Method Summary collapse

Methods inherited from BaseMatcher

#==, #description, #diffable?, #initialize, #match_unless_raises

Methods included from Pretty

#_pretty_print, #expected_to_sentence, #name, #name_to_sentence, #split_words, #to_sentence, #underscore

Constructor Details

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

Instance Method Details

#failure_message_for_shouldObject



89
90
91
# File 'lib/rspec/matchers/built_in/yield.rb', line 89

def failure_message_for_should
  "expected given block to yield with no arguments, but #{failure_reason}"
end

#failure_message_for_should_notObject



93
94
95
# File 'lib/rspec/matchers/built_in/yield.rb', line 93

def failure_message_for_should_not
  "expected given block not to yield with no arguments, but did"
end

#matches?(block) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
87
# File 'lib/rspec/matchers/built_in/yield.rb', line 84

def matches?(block)
  @probe = YieldProbe.probe(block)
  @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty?
end