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
Showing
5 changed files
with
104 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
require 'rubygems' | ||
require 'test/unit' | ||
require 'mocha' | ||
require 'shoulda' | ||
|
||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
require 'prowly' | ||
|
||
class Test::Unit::TestCase | ||
end | ||
def apikey | ||
"f" * 40 | ||
end | ||
|
||
def apikeys | ||
[apikey] * 6 | ||
end | ||
|
||
def valid_params?(params) | ||
array_of_params = params.split("&") | ||
array_of_params.each { |param, value| } | ||
end | ||
end |
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,6 @@ | ||
require 'helper' | ||
|
||
tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"] | ||
tests.each do |file| | ||
require file | ||
end |
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,51 @@ | ||
require 'helper' | ||
|
||
class TestNotification < Test::Unit::TestCase | ||
|
||
context "A Notification" do | ||
|
||
should "accept one apikey" do | ||
notification = Prowly::Notification.new(:apikey => apikey) | ||
|
||
assert_equal notification.apikey, apikey | ||
end | ||
|
||
should "accept an array of apikeys and turn it into a comma-separated keys" do | ||
notification = Prowly::Notification.new(:apikeys => apikeys) | ||
|
||
assert_equal notification.apikeys, apikeys.join(",") | ||
end | ||
|
||
should "raise an exception if apikey and apikeys are set at the same time" do | ||
assert_raises Prowly::Notification::DuplicatedAssignmentOfApiKey do | ||
notification = Prowly::Notification.new(:apikeys => apikeys, :apikey => apikey) | ||
end | ||
end | ||
|
||
should "set default parameters" do | ||
notification = Prowly::Notification.new(:apikey => apikey) | ||
assert_equal notification.application, "Prowly" | ||
assert_equal notification.event, "Prowly is working!!" | ||
assert_equal notification.description, "This is the default description" | ||
assert_equal notification.priority, Prowly::Notification::Priority::NORMAL | ||
end | ||
|
||
context "#to_params method" do | ||
should "return a string separated by &s" do | ||
notif_with_apikey = Prowly::Notification.new(:apikey => apikey, :application => "test", :description => "desc") | ||
notif_with_apikeys = Prowly::Notification.new(:apikeys => apikeys, :application => "test", :description => "desc") | ||
|
||
#check if the param were built the right way | ||
end | ||
|
||
should "raise and exception if no apikey was given" do | ||
end | ||
|
||
should "raise and exception if no application name was given" do | ||
end | ||
|
||
should "raise and exception if no description given was given" do | ||
end | ||
end | ||
end | ||
end |
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,22 @@ | ||
require 'helper' | ||
|
||
class TestPriority < Test::Unit::TestCase | ||
|
||
context "Priority module" do | ||
should "raise an exception if priority is not available" do | ||
assert_raises Prowly::Notification::PriorityNotAvailable do | ||
Prowly::Notification::Priority::NONEXISTENT_PRIORITY | ||
end | ||
end | ||
|
||
should "return numeric values for each priority" do | ||
Priority = Prowly::Notification::Priority | ||
|
||
assert_equal Priority::VERY_LOW, -2 | ||
assert_equal Priority::MODERATE, -1 | ||
assert_equal Priority::NORMAL, 0 | ||
assert_equal Priority::HIGH, 1 | ||
assert_equal Priority::EMERGENCY, 2 | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
require 'helper' | ||
|
||
class TestProwly < Test::Unit::TestCase | ||
should "probably rename this file and start testing for real" do | ||
flunk "hey buddy, you should probably rename this file and start testing for real" | ||
end | ||
end | ||
context "Prowly notification" do | ||
should "verify the key" do | ||
#response_mock = mock('Prowly::Response') | ||
#response_mock.expects(:succeeded?).returns(false).once | ||
|
||
#Prowly::Interface.instance.expects(:call).returns(response_mock).once | ||
|
||
#assert Prowly.valid_key?(apikey) | ||
end | ||
end | ||
end |