class TurnipFormatter::Resource::Scenario::Base

Attributes

example[R]

Public Class Methods

new(example) click to toggle source

@param [RSpec::Core::Example] example

# File lib/turnip_formatter/resource/scenario/base.rb, line 17
def initialize(example)
  @example = example
end

Public Instance Methods

backgrounds() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 44
def backgrounds
  feature.backgrounds
end
feature() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 52
def feature
  example.metadata[:turnip_formatter][:feature]
end
feature_info() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 39
def feature_info
  path = RSpec::Core::Metadata.relative_path(feature_file_path)
  "\"#{feature.name}\" in #{path}"
end
id() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 21
def id
  'scenario_' + object_id.to_s
end
mark_status() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 68
def mark_status
  raise NotImplementedError
end
run_time() click to toggle source

@return [Float] scenario run time (sec)

# File lib/turnip_formatter/resource/scenario/base.rb, line 35
def run_time
  execution_result.run_time
end
status() click to toggle source

@return [Symbol] scenario status (:passed | :failed | :pending)

# File lib/turnip_formatter/resource/scenario/base.rb, line 28
def status
  execution_result.status.to_sym
end
steps() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 56
def steps
  return @steps if @steps

  @steps = raw_steps.map do |step|
    TurnipFormatter::Resource::Step::Step.new(example, step)
  end

  mark_status

  @steps
end
tags() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 48
def tags
  @tags ||= (feature.tag_names + raw.tag_names).sort.uniq
end

Private Instance Methods

execution_result() click to toggle source

@return [OpenStruct or ::RSpec::Core::Example::ExecutionResult]

# File lib/turnip_formatter/resource/scenario/base.rb, line 89
def execution_result
  @execution_result ||= example.execution_result
end
feature_file_path() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 82
def feature_file_path
  example.metadata[:file_path]
end
raw() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 74
def raw
  @raw = example.metadata[:turnip_formatter][:scenario]
end
raw_steps() click to toggle source
# File lib/turnip_formatter/resource/scenario/base.rb, line 78
def raw_steps
  backgrounds.map(&:steps).flatten + raw.steps
end