Class: ParallelTests::Cucumber::GherkinListener

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_tests/cucumber/gherkin_listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGherkinListener

Returns a new instance of GherkinListener.



8
9
10
11
12
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 8

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 …



56
57
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 56

def method_missing(*args)
end

Instance Attribute Details

#collectObject (readonly)

Returns the value of attribute collect.



6
7
8
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 6

def collect
  @collect
end

Instance Method Details

#background(*args) ⇒ Object



14
15
16
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 14

def background(*args)
  @background = 1
end

#eof(*args) ⇒ Object



46
47
48
49
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 46

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

#examples(*args) ⇒ Object



42
43
44
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 42

def examples(*args)
  @examples += 1
end

#reset_counters!Object



51
52
53
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 51

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

#scenario(*args) ⇒ Object



18
19
20
21
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 18

def scenario(*args)
  @scenarios += 1
  @outline = @background = 0
end

#scenario_outline(*args) ⇒ Object



23
24
25
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 23

def scenario_outline(*args)
  @outline = 1
end

#step(*args) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 27

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

#uri(path) ⇒ Object



37
38
39
40
# File 'lib/parallel_tests/cucumber/gherkin_listener.rb', line 37

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