Class: Minitest::Libnotify::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/libnotify/notifier.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :global => {
    :timeout      => 2.5,
    :append       => false,
    :description  => proc { [ defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby", RUBY_VERSION ].join(" ") },
  },

  :pass => {
    :description  => proc { |description| "Tests PASSED #{description}" },
    :urgency      => :critical,
    :icon_path    => "face-laugh.*"
  },

  :fail => {
    :description  => proc { |description| "Tests FAILED #{description}" },
    :urgency    => :critical,
    :icon_path  => "face-angry.*"
  }
}

Instance Method Summary collapse

Constructor Details

#initializeNotifier

Returns a new instance of Notifier.



26
27
28
29
# File 'lib/minitest/libnotify/notifier.rb', line 26

def initialize
  # TODO: Write a public interface where the options can be modified (custom icon_path, description etc)
  @options = DEFAULT_OPTIONS
end

Instance Method Details

#notify(stats, state) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/minitest/libnotify/notifier.rb', line 31

def notify(stats, state)
  body =  "#{stats[:assertions]} assertions, "
  body << "#{stats[:failures]} failures, "
  body << "#{stats[:errors]} errors, "
  body << "#{stats[:skips]} skips"

  default_description = config_for(:description)
  libnotify.body      = config_for(:body, state, body)
  libnotify.summary   = config_for(:description, state, default_description)
  libnotify.urgency   = config_for(:urgency, state)
  libnotify.icon_path = config_for(:icon_path, state)
  libnotify.show!
end