Permalink
Browse files

Refactor tests for Notifier::Base

  • Loading branch information...
1 parent 9e5b2e0 commit db625d0ff914563d053e0306f996ede169ba9c87 @sr sr committed Mar 29, 2009
Showing with 43 additions and 11 deletions.
  1. +43 −0 test/unit/notifier/base_test.rb
  2. +0 −11 test/unit/notifier_test.rb
@@ -0,0 +1,43 @@
+require File.dirname(__FILE__) + "/../../helpers"
+
+class BaseNotifierTest < Test::Unit::TestCase
+ before(:each) do
+ @commit = Commit.gen(:successful)
+ @base = Notifier::Base.new(@commit, {})
+ end
+
+ it "requires to implement .to_haml" do
+ assert_raise(NotImplementedError) { Notifier::Base.to_haml }
+ end
+
+ it "requires to implement #deliver!" do
+ assert_raise(NotImplementedError) { @base.deliver! }
+ end
+
+ it "provides a short message" do
+ assert_equal "Built #{@commit.short_identifier} successfully", @base.short_message
+ end
+
+ it "provides a full message" do
+ assert @base.full_message.include?("Commit Message: #{@commit.message}")
+ assert @base.full_message.include?("Commit Date: #{@commit.committed_at}")
+ assert @base.full_message.include?("Commit Author: #{@commit.author.name}")
+ assert @base.full_message.include?("Link: #{@base.commit_url}")
+ assert @base.full_message.include?("Build Output")
+ assert @base.full_message.include?(@commit.build.output)
+ end
+
+ it "provides a commit url" do
+ assert_equal "http://localhost:8910/#{@commit.project.name}" +
+ "/commits/#{@commit.identifier}", @base.commit_url
+ end
+
+ test "deprecated methods" do
+ silence_warnings {
+ assert_equal @base.commit, @base.build
+ assert_equal @base.commit_url, @base.build_url
+ assert_equal @base.send(:stripped_commit_output),
+ @base.send(:stripped_build_output)
+ }
+ end
+end
View
@@ -1,11 +1,6 @@
require File.dirname(__FILE__) + "/../helpers"
class NotifierTest < Test::Unit::TestCase
- test "deprecated methods" do
- Notifier::Base.new(Build.gen, {}).should respond_to(:build)
- Notifier::Base.new(Build.gen, {}).should respond_to(:build_url)
- end
-
specify "IRC fixture is valid and can be saved" do
lambda do
Notifier.generate(:irc).tap do |project|
@@ -119,10 +114,4 @@ class NotifierTest < Test::Unit::TestCase
end.should_not change(project.notifiers, :count)
end
end
-
- it "requires notifier classes to implement Notifier.to_haml and Notifier#deliver!" do
- class Blah < Notifier::Base; end
- lambda { Blah.to_haml }.should raise_error(NoMethodError)
- lambda { Blah.new(Build.gen, {}).deliver! }.should raise_error(NoMethodError)
- end
end

0 comments on commit db625d0

Please sign in to comment.