Class: QAT::Formatter::TestIds

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

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(runtime, path_or_io, options) ⇒ TestIds

Returns a new instance of TestIds.

Since:

  • 0.1.0



9
10
11
12
13
14
15
16
17
18
# File 'lib/qat/formatter/test_ids.rb', line 9

def initialize(runtime, path_or_io, options)
  @io                 = ensure_io(path_or_io)
  @tags               = []
  @scenario_tags      = []
  @no_test_id         = {}
  @max_test_id        = 0
  @duplicate_test_ids = {}
  @test_id_mapping    = {}
  @options            = options
end

Instance Method Details

#after_features(features) ⇒ Object

Since:

  • 0.1.0



56
57
58
59
# File 'lib/qat/formatter/test_ids.rb', line 56

def after_features(features)
  publish_result
  @io.flush
end

#after_tags(tags) ⇒ Object

Since:

  • 0.1.0



28
29
30
# File 'lib/qat/formatter/test_ids.rb', line 28

def after_tags(tags)
  @in_scenarios = true unless @in_scenarios
end

#before_feature(feature) ⇒ Object

Since:

  • 0.1.0



20
21
22
# File 'lib/qat/formatter/test_ids.rb', line 20

def before_feature(feature)
  @in_scenarios = false
end

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

Since:

  • 0.1.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/qat/formatter/test_ids.rb', line 32

def scenario_name(keyword, name, file_colon_line, source_indent)
  if @scenario_tags.any? { |tag| tag.match(/@test#(\d+)/) }
    id           = @scenario_tags.map { |tag| tag.match(/@test#(\d+)/) }.compact.first.captures.first.to_i
    @max_test_id = id if id > @max_test_id

    test_id_info = { name: name,
                     path: file_colon_line }

    if @test_id_mapping[id]
      if @duplicate_test_ids[id]
        @duplicate_test_ids[id] << test_id_info
      else
        @duplicate_test_ids[id] = [@test_id_mapping[id], test_id_info]
      end
    else
      @test_id_mapping[id] = test_id_info
    end

  else
    @no_test_id[name] = file_colon_line unless @scenario_tags.include?('@dummy_test')
  end
  @scenario_tags = []
end

#tag_name(tag_name) ⇒ Object

Since:

  • 0.1.0



24
25
26
# File 'lib/qat/formatter/test_ids.rb', line 24

def tag_name(tag_name)
  @scenario_tags << tag_name if @in_scenarios
end