notifier 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +12 -0
- data/{README.rdoc → README.md} +56 -38
- data/Rakefile +7 -7
- data/lib/notifier.rb +5 -3
- data/lib/notifier/adapters.rb +1 -1
- data/lib/notifier/adapters/gntp.rb +4 -4
- data/lib/notifier/gntp.rb +7 -7
- data/lib/notifier/growl.rb +1 -1
- data/lib/notifier/terminal_notifier.rb +6 -1
- data/lib/notifier/version.rb +1 -1
- data/notifier.gemspec +4 -4
- data/test/notifier/notifier_test.rb +75 -0
- data/test/notifier/snarl_test.rb +9 -0
- data/test/test_helper.rb +12 -0
- metadata +40 -10
- data/.rspec +0 -1
- data/spec/notifier_spec.rb +0 -72
- data/spec/spec_helper.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5afe2f3c9c49b9f8e29be682424de92908dd35
|
4
|
+
data.tar.gz: 7b5c443d285fd023fb001b48ebe43ac695944d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56c4fbc80d2c33cb22990600f977d031335c6e4cc4df42ce3f8bd9d0da452d183df75127dcd405ea36121d23bd6aab1cd8f5200e5b7de8bafde03a768563d2af
|
7
|
+
data.tar.gz: a9a64939c8a7db0f0040baec682e6d078621b2a8328036d016469cb8e534a9d1faba0a56a64c1586c2c2eb378493e8fed57178de964bba7965539bc8e7d97ccf
|
data/.travis.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
4
|
+
notifications:
|
5
|
+
email: false
|
6
|
+
rvm:
|
7
|
+
- 2.3.0
|
8
|
+
- '2.2'
|
9
|
+
- '2.1'
|
10
|
+
env:
|
11
|
+
global:
|
12
|
+
secure: mYd3r1SEZJcirOFNjNe75vMNjYJ/UHDLZAsEeCQQcI4Na03au53Pr02waJKPdXXV8JnakaYMDNBc4kOXnk3v0ytgINnvNXnObjPT2KUPvQKLUhXq2Q/BrWS4CFihihznZHAQFgeTVbDm/brLWH61+JwDlQ2kEo6OGSAZ8ZV/PV8=
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
# Notifier
|
2
|
+
|
3
|
+
[](https://travis-ci.org/fnando/notifier)
|
4
|
+
[](https://codeclimate.com/github/fnando/notifier)
|
5
|
+
[](https://codeclimate.com/github/fnando/notifier/coverage)
|
6
|
+
[](https://rubygems.org/gems/notifier)
|
7
|
+
[](https://rubygems.org/gems/notifier)
|
2
8
|
|
3
9
|
Send system notifications on several platforms with a simple and unified API. Currently supports:
|
4
10
|
|
@@ -11,85 +17,97 @@ Send system notifications on several platforms with a simple and unified API. Cu
|
|
11
17
|
* Libnotify (Linux)
|
12
18
|
* Snarl (Windows)
|
13
19
|
|
14
|
-
|
20
|
+
## Installation
|
15
21
|
|
16
|
-
|
22
|
+
gem install notifier
|
17
23
|
|
18
|
-
|
24
|
+
### Mac OS X
|
19
25
|
|
20
|
-
Growl
|
26
|
+
#### Growl
|
21
27
|
|
22
28
|
* Install Growl - http://growl.info/
|
23
29
|
* Install the growlnotify script located on the "Extras" directory
|
24
30
|
* Open the Growl Preference Panel (System > Growl) and activate "Listen for incoming notifications" and "Allow remote application registration" options on the Network tab.
|
25
31
|
|
26
|
-
terminal-notifier
|
32
|
+
#### terminal-notifier
|
27
33
|
|
28
34
|
* Install terminal-notifier - https://github.com/alloy/terminal-notifier
|
29
35
|
|
30
|
-
|
36
|
+
terminal-notifier also supports two additional flags:
|
37
|
+
|
38
|
+
* `subtitle`
|
39
|
+
* `sound`
|
40
|
+
|
41
|
+
See terminal-notifier's help for additional information.
|
42
|
+
|
43
|
+
### Linux
|
31
44
|
|
32
45
|
If you're a linux guy, you can choose one of these methods:
|
33
46
|
|
34
|
-
* Install libnotify-bin and its dependencies:
|
35
|
-
* Install xosd-bin:
|
47
|
+
* Install libnotify-bin and its dependencies: `sudo aptitude install libnotify-bin`
|
48
|
+
* Install xosd-bin: `sudo aptitude install xosd-bin`
|
36
49
|
* KDE users don't need to install anything: Test Notifier will use +knotify+ or +kdialog+.
|
37
50
|
|
38
|
-
|
51
|
+
### Windows
|
39
52
|
|
40
53
|
* Install Snarl: download from http://www.fullphat.net
|
41
|
-
* Install ruby-snarl:
|
54
|
+
* Install ruby-snarl: `gem install ruby-snarl`
|
42
55
|
|
43
|
-
|
56
|
+
## Usage
|
44
57
|
|
45
58
|
Notifier will try to detect which notifiers are available in your system. So you can just send a message:
|
46
59
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
60
|
+
```ruby
|
61
|
+
Notifier.notify(
|
62
|
+
image: "image.png",
|
63
|
+
title: "Testing Notifier",
|
64
|
+
message: "Sending an important message!"
|
65
|
+
)
|
66
|
+
```
|
52
67
|
|
53
68
|
Not all notifiers support the image option, therefore it will be ignored.
|
54
69
|
|
55
70
|
If your system support more than one notifier, you can specify which one you prefer:
|
56
71
|
|
57
|
-
|
72
|
+
```ruby
|
73
|
+
Notifier.default_notifier = :notify_send
|
74
|
+
```
|
58
75
|
|
59
|
-
The available names are
|
76
|
+
The available names are `growl`, `terminal_notifier`, `kdialog`, `knotify`, `notify_send`, `osd_cat`, and `snarl`.
|
60
77
|
|
61
78
|
There are several helper methods that you can use in order to retrieve notifiers.
|
62
79
|
|
63
|
-
*
|
64
|
-
*
|
65
|
-
*
|
66
|
-
*
|
67
|
-
*
|
80
|
+
* `Notifier.notifier`: return the first supported notifier
|
81
|
+
* `Notifier.notifiers`: return all notifiers
|
82
|
+
* `Notifier.supported_notifiers`: return only supported notifiers
|
83
|
+
* `Notifier.from_name(name)`: find notifier by its name
|
84
|
+
* `Notifier.supported_notifier_from_name(name)`: find a supported notifier by its name
|
68
85
|
|
69
|
-
|
86
|
+
## Creating custom notifiers
|
70
87
|
|
71
|
-
To create a new notifier, just create a module on
|
88
|
+
To create a new notifier, just create a module on `Notifier` namespace that implements the following interface:
|
72
89
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
90
|
+
```ruby
|
91
|
+
module Notifier
|
92
|
+
module MyCustomNotifier
|
93
|
+
def self.supported?
|
94
|
+
end
|
77
95
|
|
78
|
-
|
79
|
-
end
|
96
|
+
def self.notify(options)
|
80
97
|
end
|
81
98
|
end
|
99
|
+
end
|
100
|
+
```
|
82
101
|
|
83
|
-
|
102
|
+
## Maintainer
|
84
103
|
|
85
|
-
* Nando Vieira - http://nandovieira.com
|
104
|
+
* Nando Vieira - http://nandovieira.com
|
86
105
|
|
87
|
-
|
106
|
+
## Contributors
|
88
107
|
|
89
|
-
|
90
|
-
* David Miani
|
108
|
+
https://github.com/fnando/notifier/graphs/contributors
|
91
109
|
|
92
|
-
|
110
|
+
## License
|
93
111
|
|
94
112
|
(The MIT License)
|
95
113
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "bundler"
|
2
|
-
Bundler::GemHelper.install_tasks
|
3
|
-
|
1
|
+
require "bundler/gem_tasks"
|
4
2
|
require "rake/testtask"
|
5
|
-
|
6
|
-
|
7
|
-
t.
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
8
6
|
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
-
t.
|
7
|
+
t.warning = false
|
10
8
|
end
|
9
|
+
|
10
|
+
task default: :test
|
data/lib/notifier.rb
CHANGED
@@ -32,13 +32,13 @@ module Notifier
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def notifiers
|
35
|
-
constants.
|
35
|
+
constants.map do |name|
|
36
36
|
const_get(name) unless %w[Placebo Adapters Version].include?(name.to_s)
|
37
37
|
end.compact + [Placebo]
|
38
38
|
end
|
39
39
|
|
40
40
|
def supported_notifiers
|
41
|
-
notifiers.select {|notifier| notifier.supported?}
|
41
|
+
notifiers.select {|notifier| notifier.supported? }
|
42
42
|
end
|
43
43
|
|
44
44
|
def from_name(name)
|
@@ -57,7 +57,9 @@ module Notifier
|
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
60
|
+
|
60
61
|
def classify(string)
|
61
|
-
string.gsub(/_(.)/sm) { "#{$1.upcase}" }
|
62
|
+
string.gsub(/_(.)/sm) { "#{$1.upcase}" }
|
63
|
+
.gsub(/^(.)/) { "#{$1.upcase}" }
|
62
64
|
end
|
63
65
|
end
|
data/lib/notifier/adapters.rb
CHANGED
@@ -8,7 +8,7 @@ module Notifier
|
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
if options.kind_of?(String)
|
11
|
-
options = {:
|
11
|
+
options = {name: options}
|
12
12
|
end
|
13
13
|
|
14
14
|
@application_name = options.fetch(:name, "GNTP/Ruby")
|
@@ -64,9 +64,9 @@ module Notifier
|
|
64
64
|
contents = File.open(path, "rb") {|f| f.read }
|
65
65
|
|
66
66
|
{
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
67
|
+
identifier: Digest::MD5.hexdigest(contents),
|
68
|
+
contents: contents,
|
69
|
+
size: contents.bytesize
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
data/lib/notifier/gntp.rb
CHANGED
@@ -21,16 +21,16 @@ module Notifier
|
|
21
21
|
|
22
22
|
def notify(options)
|
23
23
|
gntp = Adapters::GNTP.new({
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
24
|
+
name: "test_notifier",
|
25
|
+
host: host,
|
26
|
+
port: port
|
27
27
|
})
|
28
28
|
|
29
29
|
gntp.notify({
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
30
|
+
name: "status",
|
31
|
+
title: options[:title],
|
32
|
+
message: options[:message],
|
33
|
+
icon: options[:image]
|
34
34
|
})
|
35
35
|
end
|
36
36
|
end
|
data/lib/notifier/growl.rb
CHANGED
@@ -12,9 +12,14 @@ module Notifier
|
|
12
12
|
"-group", "notifier-rubygems",
|
13
13
|
"-title", options[:title].to_s,
|
14
14
|
"-appIcon", options.fetch(:image, "").to_s,
|
15
|
-
"-message", options[:message].to_s
|
15
|
+
"-message", options[:message].to_s,
|
16
|
+
"-subtitle", options.fetch(:subtitle, "").to_s
|
16
17
|
]
|
17
18
|
|
19
|
+
# -sound with an empty string (e.g., "") will trigger the
|
20
|
+
# default sound so we need to check for it.
|
21
|
+
command.concat(["-sound", options.fetch(:sound, "default").to_s] ) if options[:sound]
|
22
|
+
|
18
23
|
Thread.new { system(*command) }.join
|
19
24
|
end
|
20
25
|
end
|
data/lib/notifier/version.rb
CHANGED
data/notifier.gemspec
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "notifier/version"
|
1
|
+
require "./lib/notifier/version"
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = "notifier"
|
@@ -19,6 +17,8 @@ Gem::Specification.new do |s|
|
|
19
17
|
|
20
18
|
s.requirements << "Growl, terminal-notifier, Libnotify, OSD, KDE (Knotify and Kdialog) or Snarl"
|
21
19
|
|
22
|
-
s.add_development_dependency "
|
20
|
+
s.add_development_dependency "minitest-utils"
|
23
21
|
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "mocha"
|
23
|
+
s.add_development_dependency "codeclimate-test-reporter"
|
24
24
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class NotifierTest < Minitest::Test
|
4
|
+
setup do
|
5
|
+
Notifier.notifiers.each do |notifier|
|
6
|
+
notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
|
7
|
+
end
|
8
|
+
|
9
|
+
Notifier.default_notifier = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
test "retrieves list of supported notifiers" do
|
13
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
14
|
+
Notifier::Knotify.stubs(:supported?).returns(true)
|
15
|
+
|
16
|
+
assert_equal 3, Notifier.supported_notifiers.size
|
17
|
+
end
|
18
|
+
|
19
|
+
test "returns first available notifier" do
|
20
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
21
|
+
Notifier::Knotify.stubs(:supported?).returns(true)
|
22
|
+
|
23
|
+
assert_equal Notifier::Snarl, Notifier.notifier
|
24
|
+
end
|
25
|
+
|
26
|
+
test "prefers default notifier" do
|
27
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
28
|
+
Notifier::Knotify.stubs(:supported?).returns(true)
|
29
|
+
|
30
|
+
Notifier.default_notifier = :knotify
|
31
|
+
|
32
|
+
assert_equal Notifier::Knotify, Notifier.notifier
|
33
|
+
end
|
34
|
+
|
35
|
+
test "sends notification" do
|
36
|
+
params = {
|
37
|
+
title: "Some title",
|
38
|
+
message: "Some message",
|
39
|
+
image: "image.png"
|
40
|
+
}
|
41
|
+
|
42
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
43
|
+
Notifier::Snarl.expects(:notify).with(params)
|
44
|
+
|
45
|
+
Notifier.notify(params)
|
46
|
+
end
|
47
|
+
|
48
|
+
test "retrieves list of all notifiers" do
|
49
|
+
assert_equal 9, Notifier.notifiers.size
|
50
|
+
end
|
51
|
+
|
52
|
+
test "considers Placebo as fallback notifier" do
|
53
|
+
assert_equal Notifier::Placebo, Notifier.supported_notifiers.last
|
54
|
+
end
|
55
|
+
|
56
|
+
test "returns notifier by its name" do
|
57
|
+
assert_equal Notifier::OsdCat, Notifier.from_name(:osd_cat)
|
58
|
+
assert_equal Notifier::NotifySend, Notifier.from_name(:notify_send)
|
59
|
+
assert_equal Notifier::Growl, Notifier.from_name(:growl)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "returns notifier by its name when supported" do
|
63
|
+
Notifier::Snarl.expects(:supported?).returns(true)
|
64
|
+
assert_equal Notifier::Snarl, Notifier.supported_notifier_from_name(:snarl)
|
65
|
+
end
|
66
|
+
|
67
|
+
test "returns nil when have no supported notifiers" do
|
68
|
+
assert_nil Notifier.supported_notifier_from_name(:snarl)
|
69
|
+
end
|
70
|
+
|
71
|
+
test "returns nil when an invalid notifier name is provided" do
|
72
|
+
assert_nil Notifier.from_name(:invalid)
|
73
|
+
assert_nil Notifier.supported_notifier_from_name(:invalid)
|
74
|
+
end
|
75
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: minitest-utils
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: codeclimate-test-reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
description: Send system notifications on several platforms with a simple and unified
|
42
70
|
API. Currently supports Growl, Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
|
43
71
|
email:
|
@@ -47,9 +75,9 @@ extensions: []
|
|
47
75
|
extra_rdoc_files: []
|
48
76
|
files:
|
49
77
|
- ".gitignore"
|
50
|
-
- ".
|
78
|
+
- ".travis.yml"
|
51
79
|
- Gemfile
|
52
|
-
- README.
|
80
|
+
- README.md
|
53
81
|
- Rakefile
|
54
82
|
- lib/notifier.rb
|
55
83
|
- lib/notifier/adapters.rb
|
@@ -66,8 +94,9 @@ files:
|
|
66
94
|
- lib/notifier/version.rb
|
67
95
|
- notifier.gemspec
|
68
96
|
- resources/register-growl.scpt
|
69
|
-
-
|
70
|
-
-
|
97
|
+
- test/notifier/notifier_test.rb
|
98
|
+
- test/notifier/snarl_test.rb
|
99
|
+
- test/test_helper.rb
|
71
100
|
homepage: http://rubygems.org/gems/notifier
|
72
101
|
licenses: []
|
73
102
|
metadata: {}
|
@@ -88,11 +117,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
117
|
requirements:
|
89
118
|
- Growl, terminal-notifier, Libnotify, OSD, KDE (Knotify and Kdialog) or Snarl
|
90
119
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.5.1
|
92
121
|
signing_key:
|
93
122
|
specification_version: 4
|
94
123
|
summary: Send system notifications on several platforms with a simple and unified
|
95
124
|
API. Currently supports Growl, Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
|
96
125
|
test_files:
|
97
|
-
-
|
98
|
-
-
|
126
|
+
- test/notifier/notifier_test.rb
|
127
|
+
- test/notifier/snarl_test.rb
|
128
|
+
- test/test_helper.rb
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/notifier_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Notifier do
|
4
|
-
before do
|
5
|
-
unsupport_all_notifiers
|
6
|
-
Notifier.default_notifier = nil
|
7
|
-
end
|
8
|
-
|
9
|
-
it "retrieves list of supported notifiers" do
|
10
|
-
allow(Notifier::Snarl).to receive_messages :supported? => true
|
11
|
-
allow(Notifier::Knotify).to receive_messages :supported? => true
|
12
|
-
|
13
|
-
expect(Notifier.supported_notifiers.size).to eql(3)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns first available notifier" do
|
17
|
-
allow(Notifier::Snarl).to receive_messages :supported? => true
|
18
|
-
allow(Notifier::Knotify).to receive_messages :supported? => true
|
19
|
-
|
20
|
-
expect(Notifier.notifier).to eql(Notifier::Snarl)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "prefers default notifier" do
|
24
|
-
allow(Notifier::Snarl).to receive_messages :supported? => true
|
25
|
-
allow(Notifier::Knotify).to receive_messages :supported? => true
|
26
|
-
|
27
|
-
Notifier.default_notifier = :knotify
|
28
|
-
|
29
|
-
expect(Notifier.notifier).to eql(Notifier::Knotify)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "sends notification" do
|
33
|
-
params = {
|
34
|
-
:title => "Some title",
|
35
|
-
:message => "Some message",
|
36
|
-
:image => "image.png"
|
37
|
-
}
|
38
|
-
|
39
|
-
allow(Notifier::Snarl).to receive_messages :supported? => true
|
40
|
-
expect(Notifier::Snarl).to receive(:notify).with(params)
|
41
|
-
|
42
|
-
Notifier.notify(params)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "retrieves list of all notifiers" do
|
46
|
-
expect(Notifier.notifiers.size).to eql(9)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "considers Placebo as fallback notifier" do
|
50
|
-
expect(Notifier.supported_notifiers.last).to eql(Notifier::Placebo)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns notifier by its name" do
|
54
|
-
expect(Notifier.from_name(:osd_cat)).to eql(Notifier::OsdCat)
|
55
|
-
expect(Notifier.from_name(:notify_send)).to eql(Notifier::NotifySend)
|
56
|
-
expect(Notifier.from_name(:growl)).to eql(Notifier::Growl)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns notifier by its name when supported" do
|
60
|
-
allow(Notifier::Snarl).to receive_messages :supported? => true
|
61
|
-
expect(Notifier.supported_notifier_from_name(:snarl)).to eql(Notifier::Snarl)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns nil when have no supported notifiers" do
|
65
|
-
expect(Notifier.supported_notifier_from_name(:snarl)).to be_nil
|
66
|
-
end
|
67
|
-
|
68
|
-
it "returns nil when an invalid notifier name is provided" do
|
69
|
-
expect(Notifier.from_name(:invalid)).to be_nil
|
70
|
-
expect(Notifier.supported_notifier_from_name(:invalid)).to be_nil
|
71
|
-
end
|
72
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require "notifier"
|
2
|
-
|
3
|
-
module SpecHelpers
|
4
|
-
def unsupport_all_notifiers
|
5
|
-
Notifier.notifiers.each do |notifier|
|
6
|
-
allow(notifier).to receive_messages(:supported? => false) unless notifier == Notifier::Placebo
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.include SpecHelpers
|
13
|
-
end
|