lib/petitest/test_case.rb in petitest-0.1.3 vs lib/petitest/test_case.rb in petitest-0.2.0
- old
+ new
@@ -13,17 +13,10 @@
attr_reader :test_group_class
# @return [Petitest::TestMethod]
attr_reader :test_method
- class << self
- # @return [String]
- def prefix_to_filter_backtrace
- @prefix_to_filter_backtrace ||= ::File.expand_path("../..", __FILE__)
- end
- end
-
# @param test_group_class [Class]
# @param test_method [Petitest::TestMethod]
def initialize(
test_group_class:,
test_method:
@@ -32,76 +25,48 @@
@processed = false
@test_group_class = test_group_class
@test_method = test_method
end
- # @return [Boolean]
- def aborted?
- processed? && has_error? && !has_assertion_error?
- end
-
# @return [Array<String>, nil]
def backtrace
- if has_error?
+ if error
error.backtrace
end
end
# @return [String, nil]
def error_class_name
- if aborted?
+ if error
error.class.to_s
end
end
# @return [String, nil]
def error_message
- if aborted?
+ if error
error.to_s
end
end
- # @return [String, nil]
- def failure_additional_message
- if failed?
- error.additional_message
- end
- end
-
- # @return [String, nil]
- def failure_assertion_type_message
- if failed?
- error.assertion_type_message
- end
- end
-
# @return [Boolean]
def failed?
- processed? && has_assertion_error?
+ processed? && !error.nil?
end
# @return [Array<String>, nil]
def filtered_backtrace
@filtered_backtrace ||= begin
+ path = ::File.expand_path("../test_group.rb", __FILE__)
backtrace.reverse_each.each_with_object([]) do |line, lines|
- if line.start_with?(::File.expand_path("../assertions.rb", __FILE__))
+ if line.start_with?(path)
break lines
end
- unless line.start_with?(self.class.prefix_to_filter_backtrace)
+ unless ::Petitest.configuration.backtrace_filters.any? { |filter| filter === line }
lines << line
end
end.reverse
end
- end
-
- # @return [Boolean]
- def has_assertion_error?
- error.is_a?(::Petitest::AssertionFailureError)
- end
-
- # @return [Boolean]
- def has_error?
- !error.nil?
end
# @return [Boolean]
def passed?
processed? && error.nil?