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.



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject

ignore lots of other possible callbacks …



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

def method_missing(*); end

Instance Attribute Details

#collectObject (readonly)

Returns the value of attribute collect.



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

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.



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

def ignore_tag_pattern=(value)
  @ignore_tag_pattern = value
end

Instance Method Details

#backgroundObject



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

def background(*)
  @background = 1
end

#eofObject



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

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

#examples(examples) ⇒ Object

Parameters:

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


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

def examples(examples)
  @collect[@uri] += (@outline_steps * examples.rows.size) unless examples.rows.empty?
end

#feature(feature) ⇒ Object



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

def feature(feature)
  @feature = feature
end

#reset_counters!Object



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

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

#scenario(scenario) ⇒ Object



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

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

#scenario_outline(outline) ⇒ Object



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

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

#stepObject



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

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

#uri(path) ⇒ Object



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

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