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

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

Instance Method Summary (collapse)

Constructor Details

- (YieldWithArgs) initialize(*args)

A new instance of YieldWithArgs

184
185
186
# File 'lib/rspec/matchers/built_in/yield.rb', line 184
def initialize(*args)
  @expected = args
end

Instance Method Details

- (Object) description

203
204
205
206
207
# File 'lib/rspec/matchers/built_in/yield.rb', line 203
def description
  desc = "yield with args"
  desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" unless @expected.empty?
  desc
end

- (Object) failure_message_for_should

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

- (Object) failure_message_for_should_not

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

- (Boolean) matches?(block) Also known as: ==

Returns:

  • (Boolean)
188
189
190
191
192
# File 'lib/rspec/matchers/built_in/yield.rb', line 188
def matches?(block)
  @probe = YieldProbe.probe(block)
  @actual = @probe.single_yield_args
  @probe.yielded_once?(:yield_with_args) && args_match?
end