Class: Codeqa::RunnerDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/codeqa/runner_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner, options = {}) ⇒ RunnerDecorator

Returns a new instance of RunnerDecorator.



3
4
5
6
7
# File 'lib/codeqa/runner_decorator.rb', line 3

def initialize(runner, options={})
  @options = { :colors => true }.merge(options)
  @runner = runner
  @msg = ''
end

Instance Method Details

#details_to_sObject



21
22
23
# File 'lib/codeqa/runner_decorator.rb', line 21

def details_to_s
  error_details
end

#sourcefile_to_sObject



9
10
11
# File 'lib/codeqa/runner_decorator.rb', line 9

def sourcefile_to_s
  info("Codeqa on :'#{@runner.sourcefile.filename}'\n")
end

#success_to_sObject



13
14
15
16
17
18
19
# File 'lib/codeqa/runner_decorator.rb', line 13

def success_to_s
  if @runner.success?
    success("Passed tests: #{@runner.results.map(&:name).join(', ')}\n")
  else
    error("Failed tests: #{@runner.failures.map(&:name).join(', ')}\n")
  end
end

#to_sObject



25
26
27
28
29
30
31
# File 'lib/codeqa/runner_decorator.rb', line 25

def to_s
  @msg << sourcefile_to_s
  @msg << success_to_s
  @msg << details_to_s unless @runner.success?

  @msg
end