Class: LearnLab::Test::Runner

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

Overview

Runs a test suite. Lifted from the ‘learn-test` gem without Ironboard related code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Runner.



11
12
13
14
# File 'lib/learn_lab/test/runner.rb', line 11

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/learn_lab/test/runner.rb', line 9

def options
  @options
end

#repoObject (readonly)

Returns the value of attribute repo.



9
10
11
# File 'lib/learn_lab/test/runner.rb', line 9

def repo
  @repo
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
# File 'lib/learn_lab/test/runner.rb', line 16

def run
  strategy.check_dependencies
  strategy.run
  results = strategy.results
  strategy.cleanup unless options.fetch(:keep, false)
  results
end

#strategyObject



28
29
30
31
32
33
# File 'lib/learn_lab/test/runner.rb', line 28

def strategy
  @strategy ||= begin
    detected = strategies.map { |s| s.new(self) }.detect(&:detect)
    detected || LearnLab::Test::Strategies::None.new(self)
  end
end

#working_directoryObject



24
25
26
# File 'lib/learn_lab/test/runner.rb', line 24

def working_directory
  repo.working_directory
end