Class: Gurke::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/runner.rb

Direct Known Subclasses

DRbClient, DRbServer, LocalRunner

Defined Under Namespace

Classes: DRbClient, DRbServer, LocalRunner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Runner

Returns a new instance of Runner.



7
8
9
10
# File 'lib/gurke/runner.rb', line 7

def initialize(config, options = {})
  @config  = config
  @options = options
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/gurke/runner.rb', line 5

def config
  @config
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/gurke/runner.rb', line 5

def options
  @options
end

Instance Method Details

#builderObject



23
24
25
# File 'lib/gurke/runner.rb', line 23

def builder
  @builder ||= Builder.new
end

#hook(scope, world, context, &block) ⇒ Object



41
42
43
# File 'lib/gurke/runner.rb', line 41

def hook(scope, world, context, &block)
  config.hooks[scope].run world, context, &block
end

#reporterObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/gurke/runner.rb', line 12

def reporter
  @reporter ||= begin
    r = (options[:formatter] + '_reporter')
        .split('_')
        .map(&:capitalize)
        .join

    Reporters.const_get(r).new
  end
end

#retries(scenario) ⇒ Object



37
38
39
# File 'lib/gurke/runner.rb', line 37

def retries(scenario)
  scenario.flaky? ? config.flaky_retries : config.default_retries
end

#run(files, reporter = self.reporter) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/gurke/runner.rb', line 27

def run(files, reporter = self.reporter)
  files.map! do |file|
    split = file.split(':')
    [split[0], split[1..-1].map {|i| Integer(i) }]
  end

  features = builder.load(files.map {|file, _| file })
  features.filter(options, files).run self, reporter
end

#with_filtered_backtraceObject



45
46
47
48
49
50
51
52
53
# File 'lib/gurke/runner.rb', line 45

def with_filtered_backtrace
  yield
rescue StandardError => e
  unless options[:backtrace]
    base = File.expand_path(Gurke.root.dirname)
    e.backtrace.select! {|l| File.expand_path(l)[0...base.size] == base }
  end
  raise
end