Module: TestRunHelper

Included in:
ProjectNotification
Defined in:
app/helpers/test_run_helper.rb

Instance Method Summary collapse

Instance Method Details

#test_run_fail_summary(test_run) ⇒ Object



28
29
30
31
32
33
34
# File 'app/helpers/test_run_helper.rb', line 28

def test_run_fail_summary(test_run)
  if test_run.real_fail_count.zero?
    "the build exited unsuccessfully after running #{test_run.total_count} #{test_run.total_count == 1 ? "test" : "tests"}"
  else
    "#{test_run.real_fail_count} #{test_run.real_fail_count == 1 ? "test" : "tests"} failed"
  end
end

#test_run_summary(test_run) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/test_run_helper.rb', line 13

def test_run_summary(test_run)
  subject = {
    "pass" => "#{test_run.total_count} tests passed!",
    "fail" => test_run_fail_summary(test_run),
    "error" => "tests are broken",
    "aborted" => "aborted"
  }.fetch(
    test_run.result.to_s,
    (test_run.created_at ? "started #{distance_of_time_in_words(test_run.created_at, Time.now)} ago" : ""))

  subject << " [#{test_run.branch}]" if test_run.branch

  subject
end

#test_status(test) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/helpers/test_run_helper.rb', line 3

def test_status(test)
  case test[:status].to_s
  when "pass"; "pass"
  when "skip"; "skip"
  when "fail", "regression"; "fail"
  else
    raise NotImplementedError.new "TestRunHelper#test_status doesn't know about the status #{test[:status].inspect}"
  end
end