Permalink
Browse files

Use const_defined? for checking a constant is defined

#51 uses !(Test::Unit.constants & [:Omission, "Omission"]).empty? for
checking a constant is defined. But it's better that Module#const_defined?
is used for that propose.
  • Loading branch information...
1 parent eac828b commit e7a0ff810a9cf21678ad6704b41fc3ad093d38ff @kou kou committed May 11, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/ci/reporter/test_unit.rb
@@ -13,8 +13,8 @@ module Reporter
class Failure
def self.new(fault)
return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
- return TestUnitSkipped.new(fault) if !(Test::Unit.constants & [:Omission, "Omission"]).empty? && (fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
- return TestUnitNotification.new(fault) if !(Test::Unit.constants & [:Notification, "Notification"]).empty? && fault.kind_of?(Test::Unit::Notification)
+ return TestUnitSkipped.new(fault) if Test::Unit.const_defined?(:Omission) && (fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
+ return TestUnitNotification.new(fault) if Test::Unit.const_defined?(:Notification) && fault.kind_of?(Test::Unit::Notification)
TestUnitError.new(fault)
end
end

0 comments on commit e7a0ff8

Please sign in to comment.