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

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

Constant Summary

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

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 MatchAliases

#==, #===

Methods included from Pretty

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

Constructor Details

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

Instance Method Details

- (Object) failure_message_for_should

169
170
171
# File 'lib/rspec/matchers/built_in/yield.rb', line 169
def failure_message_for_should
  "expected given block to yield with no arguments, but #{failure_reason}"
end

- (Object) failure_message_for_should_not

173
174
175
# File 'lib/rspec/matchers/built_in/yield.rb', line 173
def failure_message_for_should_not
  "expected given block not to yield with no arguments, but did"
end

- (Boolean) matches?(block)

Returns:

  • (Boolean)
164
165
166
167
# File 'lib/rspec/matchers/built_in/yield.rb', line 164
def matches?(block)
  @probe = YieldProbe.probe(block)
  @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty?
end