module Guard::PHPUnit2::Notifier

The Guard::PHPUnit notifier displays a notification pop-up with the tests results.

Public Class Methods

notify(message, options) click to toggle source

Displays a system notification.

@param [String] message the message to show @param [Hash] options the notifier options

# File lib/guard/phpunit2/notifier.rb, line 15
def notify(message, options)
  Compat::UI.notify(message, options)
end
notify_results(test_results) click to toggle source

Displays a notification about the tests results.

@param [Hash] test_results the parsed tests results @option test_results [Integer] :tests tests count @option test_results [Integer] :failures failures count @option test_results [Integer] :errors count count @option test_results [Integer] :pending pending tests count @option test_results [Integer] :duration tests duration

# File lib/guard/phpunit2/notifier.rb, line 28
def notify_results(test_results)
  notify(message(test_results), {
    :title => 'PHPUnit results',
    :image => image(test_results)
  })
end

Private Class Methods

image(results) click to toggle source

Returns the appropriate image for the tests results.

@param (see .notify) @return [Symbol] the image symbol

# File lib/guard/phpunit2/notifier.rb, line 55
def image(results)
  if results[:failures] + results[:errors] > 0
    :failed
  elsif results[:pending] > 0
    :pending
  else
    :success
  end
end
message(results) click to toggle source

Formats the message for the tests results notifier.

@param (see .notify) @return [String] the message

# File lib/guard/phpunit2/notifier.rb, line 42
def message(results)
  message = "#{results[:tests]} tests, #{results[:failures]} failures"
  message << "\n#{results[:errors]} errors"    if results[:errors]  > 0
  message << " (#{results[:pending]} pending)" if results[:pending] > 0
  message << "\nin #{results[:duration].first} #{results[:duration].last}"
  message
end