Skip to content
Browse files

Fix and improve tests for latest Notifier::Test

  • Loading branch information...
1 parent 823961a commit e4918923a99cd0a127d5d95da83a40d296430815 @sr sr committed Mar 30, 2009
Showing with 16 additions and 6 deletions.
  1. +16 −6 test/mail_test.rb
View
22 test/mail_test.rb
@@ -1,7 +1,7 @@
require "test/unit"
require "rumbster"
require "message_observers"
-require "integrity/notifier/test_helper"
+require "integrity/notifier/test"
begin
require "redgreen"
@@ -11,7 +11,7 @@
require File.dirname(__FILE__) + "/../lib/notifier/email"
class MailTest < Test::Unit::TestCase
- include NotifierHelpers
+ include Integrity::Notifier::Test
MAIL_SERVER_PORT = 10_000
@@ -27,6 +27,12 @@ def setup
@server.add_observer(@mail_observer)
@server.start
+
+ setup_database
+ end
+
+ def commit(status=:successful)
+ Integrity::Commit.gen(status)
end
def teardown
@@ -52,15 +58,19 @@ def test_it_sends_email_notification
"to" => "you@example.org",
"from" => "me@example.org" }
- Integrity::Notifier::Email.new(commit, config).deliver!
+ successful = commit(:successful)
+ failed = commit(:failed)
+
+ Integrity::Notifier::Email.new(successful, config.dup).deliver!
+ Integrity::Notifier::Email.new(failed, config).deliver!
mail = @mail_observer.messages.first
assert_equal ["you@example.org"], mail.destinations
assert_equal ["me@example.org"], mail.from
assert mail.subject.include?("successful")
- assert mail.body.include?(commit.committed_at.to_s)
- assert mail.body.include?(commit.author.name)
- assert mail.body.include?(commit.output)
+ assert mail.body.include?(successful.committed_at.to_s)
+ assert mail.body.include?(successful.author.name)
+ assert mail.body.include?(successful.output)
end
end

0 comments on commit e491892

Please sign in to comment.
Something went wrong with that request. Please try again.