class Guard::BustedRunner

The class responsible for running 'busted' command in the proper context.

Attributes

cmd[RW]
cmd_all[RW]
cmd_all_options[RW]
cmd_options[RW]
options[RW]

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/guard/busted/runner.rb, line 8
def initialize(options)
  super

  @cmd = options[:cmd]
  @cmd_options = options[:cmd_options]
  @cmd_all = options[:cmd_all]
  @cmd_all_options = options[:cmd_all_options]
end

Public Instance Methods

run(paths) click to toggle source
# File lib/guard/busted/runner.rb, line 26
def run(paths)
  puts "Running #{paths.join(', ')}"
  results = paths.map do |path|
    if Pathname.new(path).exist?
      system([command, path].join(' '))
    else
      true
    end
  end
  throw(:task_has_failed) if results.any? { |x| x == false }
end
run_all() click to toggle source

Run all tests in the project

@raise [:task_has_failed] when run_all has failed

# File lib/guard/busted/runner.rb, line 20
def run_all
  puts 'Running all tests'
  status = system(command_all)
  throw(:task_has_failed) unless status
end

Private Instance Methods

command() click to toggle source
# File lib/guard/busted/runner.rb, line 40
def command
  [options[:cmd], *options[:cmd_options]].join(' ')
end
command_all() click to toggle source
# File lib/guard/busted/runner.rb, line 44
def command_all
  [options[:cmd_all], *options[:cmd_all_options]].join(' ')
end