Permalink
Browse files

add test case for only_fixed_and_broken_builds

* ensure coverage of finished/broke/fixed scenarios
  • Loading branch information...
1 parent ea00807 commit 7253cc91b94c0818450f7f1ef5d2c778c6ce0c3d @tardate tardate committed May 3, 2012
Showing with 62 additions and 14 deletions.
  1. +62 −14 test/unit/campfire_notifier_test.rb
View
76 test/unit/campfire_notifier_test.rb
@@ -14,6 +14,7 @@ class CampfireNotifierTest < Test::Unit::TestCase
assert_nil @campfire_notifier.room
assert_equal false, @campfire_notifier.ssl
assert_equal false, @campfire_notifier.only_failed_builds
+ assert_equal false, @campfire_notifier.only_fixed_and_broken_builds
end
should "not be enabled" do
@@ -92,47 +93,94 @@ class CampfireNotifierTest < Test::Unit::TestCase
@campfire_notifier.build_finished(@build)
end
- context "and only_failed_builds is true" do
+ context "and only_fixed_and_broken_builds is true" do
setup do
- @campfire_notifier.only_failed_builds = true
+ @campfire_notifier.only_fixed_and_broken_builds = true
end
should "not notify of build outcome" do
@campfire_notifier.expects(:notify_of_build_outcome).never
@campfire_notifier.build_finished(@build)
end
end
+
end
context "on failed build" do
setup do
- @campfire_notifier.expects(:notify_of_build_outcome).with(
- @build,
- "BROKE!"
- )
+ @build.stubs(:successful?).returns(false)
end
should "notify of build outcome" do
- @campfire_notifier.build_broken(
+ @campfire_notifier.expects(:notify_of_build_outcome).with(
@build,
- previous_build = stub('Previous Build')
+ "FAILED!"
)
+ @campfire_notifier.build_finished(@build)
+ end
+
+ context "and only_fixed_and_broken_builds is true" do
+ setup do
+ @campfire_notifier.only_fixed_and_broken_builds = true
+ end
+
+ should "not notify of build outcome" do
+ @campfire_notifier.expects(:notify_of_build_outcome).never
+ @campfire_notifier.build_finished(@build)
+ end
+ end
+
+ end
+
+
+ context "on broken build (when previous build was success)" do
+ setup do
+ @previous_build = stub('Previous Build')
end
+
+ should "not notify of build outcome" do
+ @campfire_notifier.expects(:notify_of_build_outcome).never
+ @campfire_notifier.build_broken(@build,@previous_build)
+ end
+
+ context "and only_fixed_and_broken_builds is true" do
+ setup do
+ @campfire_notifier.only_fixed_and_broken_builds = true
+ end
+
+ should "notify of build outcome" do
+ @campfire_notifier.expects(:notify_of_build_outcome).with(
+ @build,
+ "BROKE!"
+ )
+ @campfire_notifier.expects(:notify_of_build_outcome).never
+ @campfire_notifier.build_broken(@build,@previous_build)
+ end
+ end
+
end
- context "on fixed build" do
+ context "on fixed build (when previous build was broken)" do
setup do
+ @previous_build = stub('Previous Build')
+ end
+
+ should "notify of build outcome" do
@campfire_notifier.expects(:notify_of_build_outcome).with(
@build,
"WAS FIXED"
)
+ @campfire_notifier.build_fixed(@build,@previous_build)
end
- should "notify of build outcome" do
- @campfire_notifier.build_fixed(
- @build,
- previous_build = stub('Previous Build')
- )
+ context "and only_failed_builds is true" do
+ setup do
+ @campfire_notifier.only_failed_builds = true
+ end
+ should "not notify of build outcome" do
+ @campfire_notifier.expects(:notify_of_build_outcome).never
+ @campfire_notifier.build_fixed(@build,@previous_build)
+ end
end
end

0 comments on commit 7253cc9

Please sign in to comment.