Class: Guard::Hydra

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/hydra.rb

Constant Summary collapse

MATCHERS =
{
  :rspec => '**/*_spec.rb'
}

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Hydra

Returns a new instance of Hydra.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/guard/hydra.rb', line 12

def initialize(watchers = [], options = {})
  super
  @options = {
    :runner_log => 'hydra-runner.log',
    :clear_runner_log => true,
    :show_runner_log => true,
    :hydra_config => 'config/hydra.yml',
    :test_matchers => [ :rspec ],
    :all_on_start => false,
    :env => 'test'
  }.merge(@options)
end

Instance Method Details

#run_allObject



53
54
55
56
# File 'lib/guard/hydra.rb', line 53

def run_all
  Guard::UI.info "Running Hydra on all matching tests..."
  run_hydra(ensure_files(matching_tests))
end

#run_on_change(files = []) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/guard/hydra.rb', line 41

def run_on_change(files = [])
  if !(files = ensure_files(files)).empty?
    Guard::UI.info "Running Hydra on #{files.join(', ')}"
    if run_hydra(files)
      run_all if @did_fail
      @did_fail = false
    else
      @did_fail = true
    end
  end
end

#startObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/guard/hydra.rb', line 25

def start
  super
  Guard::UI.info "Guard::Hydra is waiting to run tests..."

  begin
    ENV['RAILS_ENV'] = @options[:env]
    require rails_application
  rescue LoadError
    Guard::UI.info "Not a Rails app, using default environment settings"
  end

  @did_fail = false

  run_all if @options[:all_on_start]
end