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 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

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

- (Object) failure_message_for_should_not

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

- (Boolean) matches?(block)

Returns:

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