class Fuci::Runner

Attributes

detected_tester[RW]
failures[RW]
log[RW]

Public Class Methods

create() click to toggle source
# File lib/fuci/runner.rb, line 25
def self.create
  CliOptions.run_last_command? ? CachedCommandRunner.new : new
end

Public Instance Methods

run() click to toggle source
# File lib/fuci/runner.rb, line 15
def run
  initialize_server!
  initialize_testers!
  check_build
  fetch_log
  detect_tester_failure
  cache_tester_command
  run_failures
end

Private Instance Methods

cache_tester_command() click to toggle source
# File lib/fuci/runner.rb, line 57
def cache_tester_command
  command = detected_tester.command log
  CommandCache.new(command).cache_command
end
check_build() click to toggle source
# File lib/fuci/runner.rb, line 31
def check_build
  case build_status
  when :green
    puts_with_exit 'Build is green.'
  when :yellow
    puts_with_exit 'Build has errored. Check build for more info.'
  end
end
detect_tester_failure() click to toggle source
# File lib/fuci/runner.rb, line 45
def detect_tester_failure
  self.detected_tester = testers.detect do |tester|
    tester.indicates_failure? log
  end

  if detected_tester
    puts "Failure detected: #{detected_tester.class.name.split('::').last}"
  else
    puts_with_exit 'No failure was detected by any tester plugins.'
  end
end
fetch_log() click to toggle source
# File lib/fuci/runner.rb, line 40
def fetch_log
  puts "Fetching log from build..."
  self.log = server.fetch_log
end
puts_with_exit(string) click to toggle source
# File lib/fuci/runner.rb, line 72
def puts_with_exit string
  puts string
  exit
end
run_failures() click to toggle source
# File lib/fuci/runner.rb, line 62
def run_failures
  command = detected_tester.command(log)

  IO.popen command  do |io|
    puts 'Running failed specs...'
    puts command
    io.each { |string| puts string }
  end
end