-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karl-Aksel Puulmann
committed
Feb 10, 2017
1 parent
3add0f6
commit 1395915
Showing
3 changed files
with
52 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require_relative('../../../_lib') | ||
|
||
class AddAlias < Critic::MockedPagerDutyTest | ||
before do | ||
@plugin = PagerBot::PluginManager.load_plugin "add_alias", {} | ||
end | ||
|
||
describe 'Adding an alias to user or schedule' do | ||
describe 'parsing' do | ||
it 'should parse a simple example' do | ||
got = @plugin.parse({ | ||
command: "alias", | ||
words: "karl@mycompany.com as the best-karl".split | ||
}) | ||
assert_equal got, { | ||
searched_alias: 'karl@mycompany.com', | ||
new_alias: 'the best-karl' | ||
} | ||
end | ||
end | ||
|
||
describe 'matching' do | ||
it 'should match on id, name, email by default if they are present' do | ||
assert_equal @plugin.matches_in([name: 'foo'], 'foo'), [name: 'foo'] | ||
assert_equal @plugin.matches_in([name: 'foobar'], 'foo'), [] | ||
assert_equal @plugin.matches_in([], 'aaa'), [] | ||
assert_equal @plugin.matches_in([{}], 'aaa'), [] | ||
assert_equal @plugin.matches_in([name: nil], 'aaa'), [] | ||
assert_equal @plugin.matches_in([email: 'foo'], 'foo'), [email: 'foo'] | ||
assert_equal @plugin.matches_in([id: 'foo'], 'foo'), [id: 'foo'] | ||
end | ||
end | ||
end | ||
end |