class RSpec::Maybes::BlockMaybeTarget
@private Validates the provided matcher to ensure it supports block maybes, in order to avoid user confusion when they use a block thinking the maybe will be on the return value of the block rather than the block itself.
Public Instance Methods
will(matcher, message = nil, &block)
click to toggle source
Calls superclass method
RSpec::Maybes::MaybeTarget#will
# File lib/rspec/maybes/maybe_target.rb, line 86 def will(matcher, message = nil, &block) enforce_block_maybe(matcher) super end
will_not(matcher, message = nil, &block)
click to toggle source
Calls superclass method
RSpec::Maybes::MaybeTarget#will_not
# File lib/rspec/maybes/maybe_target.rb, line 91 def will_not(matcher, message = nil, &block) enforce_block_maybe(matcher) super end
Private Instance Methods
description_of(matcher)
click to toggle source
# File lib/rspec/maybes/maybe_target.rb, line 112 def description_of(matcher) matcher.description rescue NoMethodError matcher.inspect end
enforce_block_maybe(matcher)
click to toggle source
# File lib/rspec/maybes/maybe_target.rb, line 98 def enforce_block_maybe(matcher) return if supports_block_maybes?(matcher) raise MaybeNot, "You must pass an argument rather than " \ "a block to use the provided matcher (#{description_of matcher}), or " \ "the matcher must implement `supports_block_expectations?`." end
supports_block_maybes?(matcher)
click to toggle source
# File lib/rspec/maybes/maybe_target.rb, line 106 def supports_block_maybes?(matcher) matcher.supports_block_expectations? rescue NoMethodError false end