Class: RSpec::Matchers::BuiltIn::YieldWithArgs

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

Instance Method Summary (collapse)

Methods included from MatchAliases

#==, #===

Constructor Details

- (YieldWithArgs) initialize(*args)

A new instance of YieldWithArgs

196
197
198
# File 'lib/rspec/matchers/built_in/yield.rb', line 196
def initialize(*args)
  @expected = args
end

Instance Method Details

- (Object) description

214
215
216
217
218
# File 'lib/rspec/matchers/built_in/yield.rb', line 214
def description
  desc = "yield with args"
  desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" unless @expected.empty?
  desc
end

- (Object) failure_message_for_should

206
207
208
# File 'lib/rspec/matchers/built_in/yield.rb', line 206
def failure_message_for_should
  "expected given block to yield with arguments, but #{positive_failure_reason}"
end

- (Object) failure_message_for_should_not

210
211
212
# File 'lib/rspec/matchers/built_in/yield.rb', line 210
def failure_message_for_should_not
  "expected given block not to yield with arguments, but #{negative_failure_reason}"
end

- (Boolean) matches?(block)

Returns:

  • (Boolean)
200
201
202
203
204
# File 'lib/rspec/matchers/built_in/yield.rb', line 200
def matches?(block)
  @probe = YieldProbe.probe(block)
  @actual = @probe.single_yield_args
  @probe.yielded_once?(:yield_with_args) && args_match?
end