Class: ParallelTests::Gherkin::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_tests/gherkin/listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

Returns a new instance of Listener.



10
11
12
13
14
# File 'lib/parallel_tests/gherkin/listener.rb', line 10

def initialize
  @steps, @uris = [], []
  @collect = {}
  reset_counters!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

ignore lots of other possible callbacks …



71
72
# File 'lib/parallel_tests/gherkin/listener.rb', line 71

def method_missing(*args)
end

Instance Attribute Details

#collectObject (readonly)

Returns the value of attribute collect.



6
7
8
# File 'lib/parallel_tests/gherkin/listener.rb', line 6

def collect
  @collect
end

#ignore_tag_pattern=(value) ⇒ Object (writeonly)

Sets the attribute ignore_tag_pattern

Parameters:

  • value

    the value to set the attribute ignore_tag_pattern to.



8
9
10
# File 'lib/parallel_tests/gherkin/listener.rb', line 8

def ignore_tag_pattern=(value)
  @ignore_tag_pattern = value
end

Instance Method Details

#background(*args) ⇒ Object



20
21
22
# File 'lib/parallel_tests/gherkin/listener.rb', line 20

def background(*args)
  @background = 1
end

#eof(*args) ⇒ Object



60
61
62
63
# File 'lib/parallel_tests/gherkin/listener.rb', line 60

def eof(*args)
  @collect[@uri] += (@background_steps * @scenarios)
  reset_counters!
end

#examples(examples) ⇒ Object

Parameters:

  • examples (Gherkin::Formatter::Model::Examples)


54
55
56
57
58
# File 'lib/parallel_tests/gherkin/listener.rb', line 54

def examples(examples)
  if examples.rows.size > 0
    @collect[@uri] += (@outline_steps * examples.rows.size)
  end
end

#feature(feature) ⇒ Object



16
17
18
# File 'lib/parallel_tests/gherkin/listener.rb', line 16

def feature(feature)
  @feature = feature
end

#reset_counters!Object



65
66
67
68
# File 'lib/parallel_tests/gherkin/listener.rb', line 65

def reset_counters!
  @outline = @outline_steps = @background = @background_steps = @scenarios = 0
  @ignoring = nil
end

#scenario(scenario) ⇒ Object



24
25
26
27
28
# File 'lib/parallel_tests/gherkin/listener.rb', line 24

def scenario(scenario)
  @outline = @background = 0
  return if should_ignore(scenario)
  @scenarios += 1
end

#scenario_outline(outline) ⇒ Object



30
31
32
33
# File 'lib/parallel_tests/gherkin/listener.rb', line 30

def scenario_outline(outline)
  return if should_ignore(outline)
  @outline = 1
end

#step(*args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/parallel_tests/gherkin/listener.rb', line 35

def step(*args)
  return if @ignoring
  if @background == 1
    @background_steps += 1
  elsif @outline > 0
    @outline_steps += 1
  else
    @collect[@uri] += 1
  end
end

#uri(path) ⇒ Object



46
47
48
49
# File 'lib/parallel_tests/gherkin/listener.rb', line 46

def uri(path)
  @uri = path
  @collect[@uri] = 0
end