test-unit/lib/test/unit/omission.rb in activegroonga-0.0.7 vs test-unit/lib/test/unit/omission.rb in activegroonga-1.0.0
- old
+ new
@@ -39,10 +39,14 @@
# Overridden to return long_display.
def to_s
long_display
end
+
+ def critical?
+ true
+ end
end
class OmittedError < StandardError
end
@@ -54,11 +58,11 @@
include OmissionHandler
end
end
end
- # Omit the test of part of the test.
+ # Omit the test or part of the test.
#
# Example:
# def test_omission
# omit
# # Not reached here
@@ -78,15 +82,59 @@
else
raise OmittedError.new(message)
end
end
+ # Omit the test or part of the test if _condition_ is
+ # true.
+ #
+ # Example:
+ # def test_omission
+ # omit_if("".empty?)
+ # # Not reached here
+ # end
+ #
+ # def test_omission_with_here
+ # omit_if(true) do
+ # # Not ran here
+ # end
+ # omit_if(false) do
+ # # Reached here
+ # end
+ # # Reached here too
+ # end
def omit_if(condition, *args, &block)
- omit(*args, &block) if condition
+ if condition
+ omit(*args, &block)
+ else
+ block.call if block
+ end
end
+ # Omit the test or part of the test if _condition_ is
+ # not true.
+ #
+ # Example:
+ # def test_omission
+ # omit_unless("string".empty?)
+ # # Not reached here
+ # end
+ #
+ # def test_omission_with_here
+ # omit_unless(true) do
+ # # Reached here
+ # end
+ # omit_unless(false) do
+ # # Not ran here
+ # end
+ # # Reached here too
+ # end
def omit_unless(condition, *args, &block)
- omit(*args, &block) unless condition
+ if condition
+ block.call if block
+ else
+ omit(*args, &block)
+ end
end
private
def add_omission(omission)
current_result.add_omission(omission)