Module: Deface::Utils::FailureFinder

Defined in:
lib/deface/utils/failure_finder.rb

Instance Method Summary collapse

Instance Method Details

#output_results_by_virtual_path(virtual_path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/deface/utils/failure_finder.rb', line 17

def output_results_by_virtual_path(virtual_path)
  has_failz = 0

  fails = overrides_by_virtual_path(virtual_path)
  return(has_failz += 1) if fails.nil?

  count = fails.group_by{ |o| !o.failure.nil? }
  if count.key?(true)
    has_failz += count[true].count
    puts "#{count[true].count} of #{fails.count} override(s) failed for :virtual_path => '#{virtual_path}'"
  else
    puts "0 of #{fails.count} override(s) failed for :virtual_path => '#{virtual_path}'"
  end

  fails.each do |override|
    if override.failure.nil?
      puts Rainbow(" '#{override.name}' reported no failures").green
    else
      puts Rainbow(" '#{override.name}' #{override.failure}").red
    end
  end

  has_failz
end

#overrides_by_virtual_path(virtual_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/deface/utils/failure_finder.rb', line 6

def overrides_by_virtual_path(virtual_path)
  begin
    load_template_source(virtual_path, false, true).dup
  rescue Exception => e
    puts "Error processing overrides for :virtual_path => '#{virtual_path}'"
    puts " #{e.message}"
    return nil
  end
  Deface::Override.find(:virtual_path => virtual_path)
end