class ParallelTests::Gherkin::Listener

Attributes

collect[R]
ignore_tag_pattern[W]

Public Class Methods

new() click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 10
def initialize
  @steps, @uris = [], []
  @collect = {}
  reset_counters!
end

Public Instance Methods

background(*args) click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 20
def background(*args)
  @background = 1
end
eof(*args) click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 60
def eof(*args)
  @collect[@uri] += (@background_steps * @scenarios)
  reset_counters!
end
examples(examples) click to toggle source

@param [Gherkin::Formatter::Model::Examples] examples

# 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) click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 16
def feature(feature)
  @feature = feature
end
method_missing(*args) click to toggle source

ignore lots of other possible callbacks …

# File lib/parallel_tests/gherkin/listener.rb, line 71
def method_missing(*args)
end
reset_counters!() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 30
def scenario_outline(outline)
  return if should_ignore(outline)
  @outline = 1
end
step(*args) click to toggle source
# 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) click to toggle source
# File lib/parallel_tests/gherkin/listener.rb, line 46
def uri(path)
  @uri = path
  @collect[@uri] = 0
end

Private Instance Methods

all_tags(scenario) click to toggle source

Return a combination of tags declared on this scenario/outline and the feature it belongs to

# File lib/parallel_tests/gherkin/listener.rb, line 77
def all_tags(scenario)
  (scenario.tags || []) + ((@feature && @feature.tags) || [])
end
should_ignore(scenario) click to toggle source

Set @ignoring if we should ignore this scenario/outline based on its tags

# File lib/parallel_tests/gherkin/listener.rb, line 82
def should_ignore(scenario)
  @ignoring = @ignore_tag_pattern && all_tags(scenario).find{ |tag| @ignore_tag_pattern === tag.name }
end