Class: RSpec::Trunk

Inherits:
Object
  • Object
show all
Defined in:
lib/trunk_spec_helper.rb

Overview

Trunk is a class that is used to monitor the execution of the Example class

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example) ⇒ Trunk

Returns a new instance of Trunk.



52
53
54
# File 'lib/trunk_spec_helper.rb', line 52

def initialize(example)
  @example = example
end

Class Method Details

.setupObject



46
47
48
49
50
# File 'lib/trunk_spec_helper.rb', line 46

def self.setup
  RSpec.configure do |config|
    config.around(:each, &:run_with_trunk)
  end
end

Instance Method Details

#current_exampleObject



56
57
58
# File 'lib/trunk_spec_helper.rb', line 56

def current_example
  @current_example ||= RSpec.current_example
end

#runObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/trunk_spec_helper.rb', line 60

def run
  # run the test
  @example.run
  # monitor attempts in the metadata
  if @example.[:attempt_number]
    @example.[:attempt_number] += 1
  else
    @example.[:attempt_number] = 0
  end

  # add the test to the report
  # return the report
  @testreport
end