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.



168
169
170
# File 'lib/trunk_spec_helper.rb', line 168

def initialize(example)
  @example = example
end

Class Method Details

.setupObject



158
159
160
161
162
163
164
165
166
# File 'lib/trunk_spec_helper.rb', line 158

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

Instance Method Details

#current_exampleObject



172
173
174
# File 'lib/trunk_spec_helper.rb', line 172

def current_example
  @current_example ||= RSpec.current_example
end

#runObject



176
177
178
179
180
181
182
183
184
185
# File 'lib/trunk_spec_helper.rb', line 176

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
end