test_notifier 0.3.5.rc.2 → 0.3.5.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/test_notifier.rb +6 -10
- data/test/test_helper.rb +2 -3
- data/test/test_notifier_test.rb +9 -16
- data/test_notifier.gemspec +2 -3
- metadata +20 -17
- data/lib/test_notifier/notifier/growl.rb +0 -25
- data/lib/test_notifier/notifier/kdialog.rb +0 -17
- data/lib/test_notifier/notifier/knotify.rb +0 -17
- data/lib/test_notifier/notifier/notify_send.rb +0 -17
- data/lib/test_notifier/notifier/osd_cat.rb +0 -27
- data/lib/test_notifier/notifier/placebo.rb +0 -14
- data/lib/test_notifier/notifier/snarl.rb +0 -22
- data/lib/test_notifier/notifier.rb +0 -39
- data/test/notifier_test.rb +0 -43
data/lib/test_notifier.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
require "notifier"
|
2
|
+
|
1
3
|
module TestNotifier
|
2
4
|
class << self
|
3
|
-
attr_accessor :__notifier__
|
4
5
|
attr_accessor :default_notifier
|
5
6
|
end
|
6
7
|
|
@@ -30,17 +31,12 @@ module TestNotifier
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def notifier
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
STDERR << NO_NOTIFIERS_MESSAGE if notifier == TestNotifier::Notifier::Placebo
|
38
|
-
|
39
|
-
notifier
|
40
|
-
end
|
34
|
+
Notifier.default_notifier = default_notifier
|
35
|
+
notifier = Notifier.notifier
|
36
|
+
STDERR << NO_NOTIFIERS_MESSAGE if notifier == Notifier::Placebo
|
37
|
+
notifier
|
41
38
|
end
|
42
39
|
|
43
|
-
autoload :Notifier, "test_notifier/notifier"
|
44
40
|
autoload :Runner, "test_notifier/runner"
|
45
41
|
autoload :Stats, "test_notifier/stats"
|
46
42
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,9 +7,8 @@ require "test_notifier"
|
|
7
7
|
class Test::Unit::TestCase
|
8
8
|
private
|
9
9
|
def unsupport_all_notifiers
|
10
|
-
|
11
|
-
notifier
|
12
|
-
notifier.stubs(:supported?).returns(false)
|
10
|
+
Notifier.notifiers.each do |notifier|
|
11
|
+
notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
data/test/test_notifier_test.rb
CHANGED
@@ -2,34 +2,27 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class TestNotifierTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
TestNotifier.__notifier__ = nil
|
6
5
|
unsupport_all_notifiers
|
7
6
|
end
|
8
7
|
|
9
|
-
test "
|
10
|
-
|
11
|
-
|
8
|
+
test "use default notifier" do
|
9
|
+
Notifier::Growl.stubs(:supported?).returns(true)
|
10
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
11
|
+
TestNotifier.default_notifier = :snarl
|
12
12
|
|
13
|
-
assert_equal
|
14
|
-
end
|
15
|
-
|
16
|
-
test "return next available notifier when default notifier is not supported" do
|
17
|
-
TestNotifier.default_notifier = :osd_cat
|
18
|
-
TestNotifier::Notifier::Snarl.expects(:supported?).returns(true)
|
19
|
-
|
20
|
-
assert_equal TestNotifier::Notifier::Snarl, TestNotifier.notifier
|
13
|
+
assert_equal Notifier::Snarl, TestNotifier.notifier
|
21
14
|
end
|
22
15
|
|
23
16
|
test "output error message to $stderr when there's no supported notifier" do
|
24
17
|
STDERR.expects(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE).once
|
25
|
-
|
26
|
-
|
18
|
+
Notifier::Placebo.expects(:supported?).returns(true)
|
19
|
+
Notifier::Placebo.expects(:notify).once
|
27
20
|
TestNotifier.notify :status => :fail, :message => "You have failed!"
|
28
21
|
end
|
29
22
|
|
30
23
|
test "send notification to supported notifier" do
|
31
|
-
|
32
|
-
|
24
|
+
Notifier::Snarl.expects(:supported?).returns(true)
|
25
|
+
Notifier::Snarl.expects(:notify).with({
|
33
26
|
:status => :fail,
|
34
27
|
:message => "You have failed!",
|
35
28
|
:title => TestNotifier::TITLES[:fail],
|
data/test_notifier.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "test_notifier/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "test_notifier"
|
7
|
-
s.version = "#{TestNotifier::Version::STRING}.rc.
|
7
|
+
s.version = "#{TestNotifier::Version::STRING}.rc.3"
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Nando Vieira"]
|
10
10
|
s.email = ["fnando.vieira@gmail.com"]
|
@@ -21,8 +21,7 @@ DESC
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.
|
25
|
-
|
24
|
+
s.add_dependency "notifier"
|
26
25
|
s.add_development_dependency "test-unit"
|
27
26
|
s.add_development_dependency "mocha"
|
28
27
|
end
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 3
|
8
8
|
- 5
|
9
9
|
- rc
|
10
|
-
-
|
11
|
-
version: 0.3.5.rc.
|
10
|
+
- 3
|
11
|
+
version: 0.3.5.rc.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Nando Vieira
|
@@ -20,7 +20,7 @@ date: 2010-11-12 00:00:00 -02:00
|
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
name:
|
23
|
+
name: notifier
|
24
24
|
prerelease: false
|
25
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
@@ -30,10 +30,10 @@ dependencies:
|
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
version: "0"
|
33
|
-
type: :
|
33
|
+
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: test-unit
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -45,6 +45,19 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
48
61
|
description: |
|
49
62
|
Display system notifications (dbus, growl and snarl) after
|
50
63
|
running tests. It works on Mac OS X, Linux and Windows. Powerful when used
|
@@ -64,14 +77,6 @@ files:
|
|
64
77
|
- Rakefile
|
65
78
|
- lib/test_notifier.rb
|
66
79
|
- lib/test_notifier/autotest.rb
|
67
|
-
- lib/test_notifier/notifier.rb
|
68
|
-
- lib/test_notifier/notifier/growl.rb
|
69
|
-
- lib/test_notifier/notifier/kdialog.rb
|
70
|
-
- lib/test_notifier/notifier/knotify.rb
|
71
|
-
- lib/test_notifier/notifier/notify_send.rb
|
72
|
-
- lib/test_notifier/notifier/osd_cat.rb
|
73
|
-
- lib/test_notifier/notifier/placebo.rb
|
74
|
-
- lib/test_notifier/notifier/snarl.rb
|
75
80
|
- lib/test_notifier/rspec.rb
|
76
81
|
- lib/test_notifier/runner.rb
|
77
82
|
- lib/test_notifier/runner/autotest.rb
|
@@ -85,7 +90,6 @@ files:
|
|
85
90
|
- resources/fail.png
|
86
91
|
- resources/register-growl.scpt
|
87
92
|
- resources/success.png
|
88
|
-
- test/notifier_test.rb
|
89
93
|
- test/stats_test.rb
|
90
94
|
- test/test_helper.rb
|
91
95
|
- test/test_notifier_test.rb
|
@@ -117,15 +121,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
121
|
- 3
|
118
122
|
- 1
|
119
123
|
version: 1.3.1
|
120
|
-
requirements:
|
121
|
-
|
124
|
+
requirements: []
|
125
|
+
|
122
126
|
rubyforge_project:
|
123
127
|
rubygems_version: 1.3.7
|
124
128
|
signing_key:
|
125
129
|
specification_version: 3
|
126
130
|
summary: Display system notifications (dbus, growl and snarl) after running tests.
|
127
131
|
test_files:
|
128
|
-
- test/notifier_test.rb
|
129
132
|
- test/stats_test.rb
|
130
133
|
- test/test_helper.rb
|
131
134
|
- test/test_notifier_test.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module Growl
|
4
|
-
extend self
|
5
|
-
|
6
|
-
SCRIPT = File.dirname(__FILE__) + "/../../../resources/register-growl.scpt"
|
7
|
-
FILE = File.expand_path("~/.test_notifier-growl")
|
8
|
-
|
9
|
-
def supported?
|
10
|
-
RUBY_PLATFORM =~ /darwin/ && `ps -Al | grep GrowlHelper` && `which growlnotify` && $?.exitstatus == 0
|
11
|
-
end
|
12
|
-
|
13
|
-
def notify(options)
|
14
|
-
Thread.new do
|
15
|
-
`growlnotify -n test_notifier --image #{options[:image]} -p 2 -m '#{options[:message]}' -t '#{options[:title]}'`
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def register
|
20
|
-
return if File.file?(FILE)
|
21
|
-
system "osascript #{SCRIPT} > #{FILE}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module Kdialog
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
RUBY_PLATFORM =~ /(linux|freebsd)/ && `which kdialog > /dev/null` && $? == 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def notify(options)
|
11
|
-
Thread.new do
|
12
|
-
`kdialog --title #{options[:title]} --passivepopup \"#{options[:message]}\" 5`
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module Knotify
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
RUBY_PLATFORM =~ /(linux|freebsd)/ && `ps -Al | grep dcop` && $?.exitstatus == 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def notify(options)
|
11
|
-
Thread.new do
|
12
|
-
`dcop knotify default notify eventname \'#{options[:title]}\' \'#{options[:message]}\' '' '' 16 2`
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module NotifySend
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
RUBY_PLATFORM =~ /(linux|freebsd)/ && `which notify-send > /dev/null` && $? == 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def notify(options)
|
11
|
-
Thread.new do
|
12
|
-
`notify-send -i #{options[:image]} #{options[:title]} \"#{options[:message]}\"`
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module OsdCat
|
4
|
-
extend self
|
5
|
-
|
6
|
-
FONT = "-bitstream-charter-bold-r-normal--33-240-100-100-p-206-iso8859-1"
|
7
|
-
POSITION = "top"
|
8
|
-
POSITION_OFFSET = "0"
|
9
|
-
ALIGN = "center"
|
10
|
-
COLORS = {
|
11
|
-
:fail => "orange",
|
12
|
-
:success => "green",
|
13
|
-
:error => "red"
|
14
|
-
}
|
15
|
-
|
16
|
-
def supported?
|
17
|
-
RUBY_PLATFORM =~ /(linux|freebsd)/ && `which osd_cat > /dev/null` && $? == 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def notify(options)
|
21
|
-
Thread.new do
|
22
|
-
`echo #{options[:message].inspect} | osd_cat --font=#{FONT} --shadow=0 --pos=#{POSITION} -o #{POSITION_OFFSET} --delay=4 --outline=4 --align=#{ALIGN} -c #{COLORS[options[:status]]}`
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
module Snarl
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
return false unless RUBY_PLATFORM =~ /(mswin|mingw)/
|
8
|
-
|
9
|
-
begin
|
10
|
-
require "snarl" unless defined?(::Snarl)
|
11
|
-
true
|
12
|
-
rescue LoadError
|
13
|
-
false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def notify(options)
|
18
|
-
::Snarl.show_message(options[:title], options[:message], options[:image])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module TestNotifier
|
2
|
-
module Notifier
|
3
|
-
autoload :Growl, "test_notifier/notifier/growl"
|
4
|
-
autoload :Snarl, "test_notifier/notifier/snarl"
|
5
|
-
autoload :OsdCat, "test_notifier/notifier/osd_cat"
|
6
|
-
autoload :Knotify, "test_notifier/notifier/knotify"
|
7
|
-
autoload :Kdialog, "test_notifier/notifier/kdialog"
|
8
|
-
autoload :NotifySend, "test_notifier/notifier/notify_send"
|
9
|
-
autoload :Placebo, "test_notifier/notifier/placebo"
|
10
|
-
|
11
|
-
extend self
|
12
|
-
|
13
|
-
def notifiers
|
14
|
-
constants.collect do |name|
|
15
|
-
const_get(name) unless name.to_s == "Placebo"
|
16
|
-
end.compact + [Placebo]
|
17
|
-
end
|
18
|
-
|
19
|
-
def supported_notifiers
|
20
|
-
notifiers.select {|notifier| notifier.supported?}
|
21
|
-
end
|
22
|
-
|
23
|
-
def from_name(name)
|
24
|
-
notifier = const_get(classify(name.to_s))
|
25
|
-
rescue Exception
|
26
|
-
nil
|
27
|
-
end
|
28
|
-
|
29
|
-
def supported_notifier_from_name(name)
|
30
|
-
notifier = from_name(name)
|
31
|
-
notifier && notifier.supported? ? notifier : nil
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def classify(string)
|
36
|
-
string.gsub(/_(.)/sm) { "#{$1.upcase}" }.gsub(/^(.)/) { "#{$1.upcase}" }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/test/notifier_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestNotifier::NotifierTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
unsupport_all_notifiers
|
6
|
-
end
|
7
|
-
|
8
|
-
test "retrieve list of supported notifiers" do
|
9
|
-
TestNotifier::Notifier::Snarl.expects(:supported?).returns(true)
|
10
|
-
TestNotifier::Notifier::Knotify.expects(:supported?).returns(true)
|
11
|
-
|
12
|
-
assert_equal 2, TestNotifier::Notifier.supported_notifiers.size
|
13
|
-
end
|
14
|
-
|
15
|
-
test "retrieve list of all notifiers" do
|
16
|
-
assert_equal 7, TestNotifier::Notifier.notifiers.size
|
17
|
-
end
|
18
|
-
|
19
|
-
test "consider Placebo as fallback notifier" do
|
20
|
-
assert_equal TestNotifier::Notifier::Placebo, TestNotifier::Notifier.notifiers.last
|
21
|
-
end
|
22
|
-
|
23
|
-
test "return notifier by its name" do
|
24
|
-
assert_equal TestNotifier::Notifier::OsdCat, TestNotifier::Notifier.from_name(:osd_cat)
|
25
|
-
assert_equal TestNotifier::Notifier::NotifySend, TestNotifier::Notifier.from_name(:notify_send)
|
26
|
-
assert_equal TestNotifier::Notifier::Growl, TestNotifier::Notifier.from_name(:growl)
|
27
|
-
end
|
28
|
-
|
29
|
-
test "return notifier by its name when supported" do
|
30
|
-
TestNotifier::Notifier::Snarl.expects(:supported?).returns(true)
|
31
|
-
|
32
|
-
assert_equal TestNotifier::Notifier::Snarl, TestNotifier::Notifier.supported_notifier_from_name(:snarl)
|
33
|
-
end
|
34
|
-
|
35
|
-
test "return nil when have supported notifiers" do
|
36
|
-
assert_nil TestNotifier::Notifier.supported_notifier_from_name(:snarl)
|
37
|
-
end
|
38
|
-
|
39
|
-
test "return nil when an invalid notifier name is provided" do
|
40
|
-
assert_nil TestNotifier::Notifier.from_name(:invalid)
|
41
|
-
assert_nil TestNotifier::Notifier.supported_notifier_from_name(:invalid)
|
42
|
-
end
|
43
|
-
end
|