Class: QAT::Formatter::Scenario::Name

Inherits:
Object
  • Object
show all
Includes:
Cucumber::Formatter::Io
Defined in:
lib/qat/formatter/scenario/name.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(runtime, path_or_io, options) ⇒ Name

Returns a new instance of Name.

Since:

  • 0.1.0



10
11
12
13
14
15
16
17
# File 'lib/qat/formatter/scenario/name.rb', line 10

def initialize(runtime, path_or_io, options)
  @runtime   = runtime
  @io        = ensure_io(path_or_io)
  @to_file   = (@io != $stdout)
  @options   = options
  @scenarios = {}
  @repeated  = {}
end

Instance Method Details

#after_features(features) ⇒ Object

Since:

  • 0.1.0



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/qat/formatter/scenario/name.rb', line 31

def after_features(features)
  if @to_file
    content = {
      scenarios: @scenarios,
      repeated:  @repeated
    }
    @io.puts(content.to_json({
                               indent:    ' ',
                               space:     ' ',
                               object_nl: "\n"
                             }))
  end
end

#scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qat/formatter/scenario/name.rb', line 19

def scenario_name(keyword, name, file_colon_line, source_indent)
  if @to_file
    if @scenarios.values.include?(name)
      @repeated[name] ||= []
      @repeated[name] << file_colon_line
    end
    @scenarios[file_colon_line] = name
  else
    puts "#{name}: #{file_colon_line}"
  end
end