Skip to content

Commit

Permalink
added specs + test configs
Browse files Browse the repository at this point in the history
  • Loading branch information
auxesis committed Nov 25, 2009
1 parent bec87f4 commit 845fadc
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/configs/flapjack-notifier-couchdb.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# top level
[notifier]
notifier-directories = /usr/lib/flapjack/notifiers/ /path/to/my/notifiers
notifiers = mailer, xmpp

[persistence]
backend = couchdb
host = localhost
port = 5984
username = spoons
password = doom

[transport]
backend = beanstalkd
basedir = /usr/lib/flapjack/persistence/
host = localhost
port = 11300

[mailer-notifier]
from_address = [email protected]

[xmpp-notifier]
jid = [email protected]
password = barfoo

25 changes: 25 additions & 0 deletions spec/configs/flapjack-notifier.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# top level
[notifier]
notifier-directories = /usr/lib/flapjack/notifiers/ /path/to/my/notifiers
notifiers = mailer, xmpp

# persistence layers
[persistence]
backend = datamapper
uri = sqlite3:///tmp/flapjack.db

# message transports
[transport]
backend = beanstalkd
basedir = /usr/lib/flapjack/persistence/
host = localhost
port = 11300

# notifiers
[mailer-notifier]
from_address = [email protected]

[xmpp-notifier]
jid = [email protected]
password = barfoo

14 changes: 14 additions & 0 deletions spec/configs/recipients.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# recipients

[John Doe]
email = [email protected]
jid = [email protected]
phone = +61 400 111 222
pager = 61400111222

[Jane Doe]
email = [email protected]
jid = [email protected]
phone = +61 222 333 111
pager = 61222333111

51 changes: 51 additions & 0 deletions spec/notifier_options_multiplexer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'cli', 'notifier')

describe "notifier options multiplexer" do

before(:all) do
@config_filename = File.join(File.dirname(__FILE__), 'configs', 'flapjack-notifier.ini')
@recipients_filename = File.join(File.dirname(__FILE__), 'configs', 'recipients.ini')

@couchdb_config_filename = File.join(File.dirname(__FILE__), 'configs', 'flapjack-notifier-couchdb.ini')
end

it "should setup notifier options from specified config file" do
args = ["-c", @config_filename, "-r", @recipients_filename]
config = Flapjack::Notifier::Options.parse(args)
config.notifiers.each do |notifier|
%w(mailer xmpp).include?(notifier.keys.first)
end

config.notifier_directories.each do |dir|
%w(/usr/lib/flapjack/notifiers/ /path/to/my/notifiers).include?(dir)
end
end

it "should setup beanstalkd transport options from specified config file" do
args = ["-c", @config_filename, "-r", @recipients_filename]
config = Flapjack::Notifier::Options.parse(args)
config.transport.backend.should == "beanstalkd"
config.transport.host.should == "localhost"
config.transport.port.should == "11300"
end

it "should setup datamapper persistence options from specified config file" do
args = ["-c", @config_filename, "-r", @recipients_filename]
config = Flapjack::Notifier::Options.parse(args)
config.persistence.backend.should == "datamapper"
config.persistence.uri.should == "sqlite3:///tmp/flapjack.db"
end

it "should setup couchdb persistence backend from specified config file" do
args = [ "-c", @couchdb_config_filename, "-r", @recipients_filename ]
config = Flapjack::Notifier::Options.parse(args)
config.persistence.backend.should == "couchdb"
config.persistence.host.should == "localhost"
config.persistence.port.should == "5984"
config.persistence.username.should == "spoons"
config.persistence.password.should == "doom"
end

end


0 comments on commit 845fadc

Please sign in to comment.