Class: Bacon::Specification

Inherits:
Object
  • Object
show all
Includes:
Mocha::API
Defined in:
lib/mocha-on-bacon.rb

Instance Method Summary collapse

Instance Method Details

#execute_blockObject


27
28
29
30
31
32
33
34
35
# File 'lib/mocha-on-bacon.rb', line 27

def execute_block
  execute_block_before_mocha do
    begin
      yield
    rescue Mocha::ExpectationError => e
      raise Error.new(:failed, e.message).tap {|ne| ne.set_backtrace(e.backtrace) }
    end
  end
end

#execute_block_before_mochaObject


26
# File 'lib/mocha-on-bacon.rb', line 26

alias_method :execute_block_before_mocha, :execute_block

#finalizeObject


38
39
40
41
42
43
44
45
46
# File 'lib/mocha-on-bacon.rb', line 38

def finalize
  # If an exception already occurred, we don't need to verify Mocha
  # expectations anymore, as the test has already failed.
  unless @exception_occurred
    execute_block { @context.mocha_verify(MochaRequirementsCounter) }
  end
  @context.mocha_teardown
  finalize_before_mocha
end

#finalize_before_mochaObject


37
# File 'lib/mocha-on-bacon.rb', line 37

alias_method :finalize_before_mocha, :finalize

#runObject


21
22
23
24
# File 'lib/mocha-on-bacon.rb', line 21

def run
  @context.mocha_setup
  run_before_mocha
end

#run_before_mochaObject


20
# File 'lib/mocha-on-bacon.rb', line 20

alias_method :run_before_mocha, :run