Class: TurnipFormatter::Scenario::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/turnip_formatter/scenario/base.rb

Direct Known Subclasses

Failure, Pass, Pending

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example) ⇒ Base

Returns a new instance of Base.

Parameters:

  • example (RSpec::Core::Example)


11
12
13
14
15
16
# File 'lib/turnip_formatter/scenario/base.rb', line 11

def initialize(example)
  @example = example
  @errors  = []

  validation
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/turnip_formatter/scenario/base.rb', line 6

def errors
  @errors
end

#exampleObject (readonly)

Returns the value of attribute example.



6
7
8
# File 'lib/turnip_formatter/scenario/base.rb', line 6

def example
  @example
end

Instance Method Details

#feature_infoObject



53
54
55
56
# File 'lib/turnip_formatter/scenario/base.rb', line 53

def feature_info
  path = RSpec::Core::Metadata.relative_path(feature_file_path)
  "\"#{feature_name}\" in #{path}"
end

#feature_nameObject



58
59
60
# File 'lib/turnip_formatter/scenario/base.rb', line 58

def feature_name
  parent_example_group[:description]
end

#idObject



28
29
30
# File 'lib/turnip_formatter/scenario/base.rb', line 28

def id
  'scenario_' + object_id.to_s
end

#nameString

Returns scenario name.

Returns:

  • (String)

    scenario name



35
36
37
# File 'lib/turnip_formatter/scenario/base.rb', line 35

def name
  example.example_group.description
end

#run_timeString

Returns scenario run time.

Returns:

  • (String)

    scenario run time



49
50
51
# File 'lib/turnip_formatter/scenario/base.rb', line 49

def run_time
  execution_result.run_time
end

#statusString

Returns scenario status (‘passed’, ‘failed’ or ‘pending’).

Returns:

  • (String)

    scenario status (‘passed’, ‘failed’ or ‘pending’)



42
43
44
# File 'lib/turnip_formatter/scenario/base.rb', line 42

def status
  execution_result.status.to_s
end

#stepsObject



22
23
24
25
26
# File 'lib/turnip_formatter/scenario/base.rb', line 22

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

#tagsObject



62
63
64
# File 'lib/turnip_formatter/scenario/base.rb', line 62

def tags
  example.[:turnip_formatter][:tags]
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/turnip_formatter/scenario/base.rb', line 18

def valid?
  errors.empty?
end