Skip to content

Commit

Permalink
Test snarl notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Apr 7, 2016
1 parent 67f8498 commit 197cb5e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/notifier.rb
Expand Up @@ -57,6 +57,7 @@ def os?(regex)
end

private

def classify(string)
string.gsub(/_(.)/sm) { "#{$1.upcase}" }.gsub(/^(.)/) { "#{$1.upcase}" }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/notifier/growl.rb
Expand Up @@ -14,7 +14,7 @@ def notify(options)
command = [
"growlnotify",
"--name", "test_notifier",
"--image", options.fetch(:image, '').to_s,
"--image", options.fetch(:image, "").to_s,
"--priority", "2",
"--message", options[:message].to_s,
options[:title].to_s
Expand Down
5 changes: 4 additions & 1 deletion test/notifier/notifier_test.rb
Expand Up @@ -2,7 +2,10 @@

class NotifierTest < Minitest::Test
setup do
unsupport_all_notifiers
Notifier.notifiers.each do |notifier|
notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
end

Notifier.default_notifier = nil
end

Expand Down
9 changes: 9 additions & 0 deletions test/notifier/snarl_test.rb
@@ -0,0 +1,9 @@
require "test_helper"

class SnarlTest < Minitest::Test
test "sends notification" do
Snarl.expects(:show_message).with("TITLE", "MESSAGE", "IMAGE")

Notifier::Snarl.notify(title: "TITLE", message: "MESSAGE", image: "IMAGE")
end
end
9 changes: 2 additions & 7 deletions test/test_helper.rb
Expand Up @@ -6,12 +6,7 @@
require "minitest/utils"
require "minitest/autorun"

module Minitest
class Test
def unsupport_all_notifiers
Notifier.notifiers.each do |notifier|
notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
end
end
module Snarl
def self.show_message(*)
end
end

0 comments on commit 197cb5e

Please sign in to comment.