Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs

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

Instance Method Summary (collapse)

Constructor Details

- (YieldSuccessiveArgs) initialize(*args)

A new instance of YieldSuccessiveArgs

254
255
256
# File 'lib/rspec/matchers/built_in/yield.rb', line 254
def initialize(*args)
  @expected = args
end

Instance Method Details

- (Object) description

277
278
279
280
281
# File 'lib/rspec/matchers/built_in/yield.rb', line 277
def description
  desc = "yield successive args"
  desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")"
  desc
end

- (Object) failure_message_for_should

265
266
267
268
269
# File 'lib/rspec/matchers/built_in/yield.rb', line 265
def failure_message_for_should
  "expected given block to yield successively with arguments, but yielded with unexpected arguments" +
    "\nexpected: #{@expected.inspect}" +
    "\n     got: #{@actual.inspect} (compared using === and ==)"
end

- (Object) failure_message_for_should_not

271
272
273
274
275
# File 'lib/rspec/matchers/built_in/yield.rb', line 271
def failure_message_for_should_not
  "expected given block not to yield successively with arguments, but yielded with expected arguments" +
      "\nexpected not: #{@expected.inspect}" +
      "\n         got: #{@actual.inspect} (compared using === and ==)"
end

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

Returns:

  • (Boolean)
258
259
260
261
262
# File 'lib/rspec/matchers/built_in/yield.rb', line 258
def matches?(block)
  @probe = YieldProbe.probe(block)
  @actual = @probe.successive_yield_args
  args_match?
end