Skip to content

Commit

Permalink
add final tests to ensure 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeridth committed Dec 26, 2009
1 parent ceefbdc commit 1416122
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 14 deletions.
34 changes: 34 additions & 0 deletions test/test_helper.rb
Expand Up @@ -6,3 +6,37 @@
class Test::Unit::TestCase
end

module CruiseControl
class Log
def self.debug(message)
true
end
end
end

class Configuration
def self.dashboard_url
"http://tempuri.org"
end
end

class Revision
attr_accessor :committed_by
def initialize(committed_by)
@committed_by = committed_by
end
end

module SourceControl
class LogParser
def parse(changeset_array)
a = []
for k in 1..20
revision = Revision.new('committerabc')
a << revision
end
a
end
end
end

42 changes: 28 additions & 14 deletions test/unit/campfire_notifier_test.rb
@@ -1,20 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/../../campfire_notifier'

module CruiseControl
class Log
def self.debug(message)
true
end
end
end

class Configuration
def self.dashboard_url
"http://tempuri.org"
end
end

class CampfireNotifierTest < Test::Unit::TestCase
context "Campfire Notifier" do
setup do
Expand Down Expand Up @@ -116,6 +102,34 @@ class CampfireNotifierTest < Test::Unit::TestCase
end
end

context "and trac url provided" do
setup do
@campfire_notifier.trac_url = 'http://temptracuri.org'
@revisions = stub('Revisions', :first => stub('first', :number => '123'),
:last => stub('last', :number => '234'))
end

should "return trac url with query" do
trac_url_with_query = @campfire_notifier.trac_url_with_query(@revisions)
assert_equal "http://temptracuri.org?new=123&old=234", trac_url_with_query
end
end

context "and changeset exists" do
setup do
changeset = 'Build was manually requested.\nRevision ...a124eaf committed by John Smith <jsmith@company.com> on 2009-12-20 09:58:14\n\n made change\n\napp/controllers/application_controller.rb | 4 ++--\n1 files changed, 2 insertions(+), 2 deletions(-)'
@build = stub('Build', :changeset => changeset,
:project => stub('Project',
:source_control => stub('source control',
:class => 'SourceControl')))
end

should "return changeset committers" do
committers = @campfire_notifier.get_changeset_committers(@build)
assert_equal ["committerabc"], committers
end
end

should "show the build label, image, project name, and message in campfire" do
office_room = stub('Room', :name => 'Office')
@campfire_notifier.stubs(:connect).returns(office_room)
Expand Down

0 comments on commit 1416122

Please sign in to comment.