Module: XSpec::AssertionContext::Doubles::AutoVerify

Defined in:
lib/xspec/assertion_contexts.rb

Overview

Most of the time, ‘assert_exhausted` will not be called directly, since the `:auto_verify` option can be used to call it by default on all doubles. That option mixes in this `AutoVerify` module to augment methods necessary for this behaviour.

Instance Method Summary collapse

Instance Method Details

#call(unit_of_work) ⇒ Object



303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/xspec/assertion_contexts.rb', line 303

def call(unit_of_work)
  result = super

  if result.empty?
    @doubles.each do |double|
      assert_exhausted double
    end
  end

  result
rescue DoubleFailure => e
  [Failure.new(unit_of_work, e.message, e.backtrace)]
end

#class_double(klass) ⇒ Object



317
318
319
320
321
# File 'lib/xspec/assertion_contexts.rb', line 317

def class_double(klass)
  x = super
  @doubles << x
  x
end

#initializeObject



299
300
301
# File 'lib/xspec/assertion_contexts.rb', line 299

def initialize
  @doubles = []
end

#instance_double(klass) ⇒ Object



323
324
325
326
327
# File 'lib/xspec/assertion_contexts.rb', line 323

def instance_double(klass)
  x = super
  @doubles << x
  x
end