class Attestify::Test
This is the base class for all Attestify
tests.
Public Class Methods
current_test()
click to toggle source
# File lib/attestify/test.rb, line 27 def self.current_test Thread.current[:Attestify_Test_CurrentTest] end
inherited(test_class)
click to toggle source
# File lib/attestify/test.rb, line 13 def self.inherited(test_class) tests << test_class end
new(method)
click to toggle source
# File lib/attestify/test.rb, line 8 def initialize(method) @_test_method = method @_assertions = Attestify::AssertionResults.new end
run(reporter, filter = nil)
click to toggle source
# File lib/attestify/test.rb, line 21 def self.run(reporter, filter = nil) runnable_methods.each do |method| run_one_method(self, method, reporter, filter) end end
run_one_method(test_class, method, reporter, filter = nil)
click to toggle source
# File lib/attestify/test.rb, line 31 def self.run_one_method(test_class, method, reporter, filter = nil) return if filter && !filter.run?(test_class, method) begin test = test_class.new(method) Thread.current[:Attestify_Test_CurrentTest] = test reporter.record test.run ensure Thread.current[:Attestify_Test_CurrentTest] = nil end end
runnable_methods()
click to toggle source
# File lib/attestify/test.rb, line 43 def self.runnable_methods instance_methods.select { |method| method.to_s.start_with?("test_") } end
tests()
click to toggle source
# File lib/attestify/test.rb, line 17 def self.tests @tests ||= [] end
Public Instance Methods
assertions()
click to toggle source
# File lib/attestify/test.rb, line 51 def assertions @_assertions end
assertions_total()
click to toggle source
# File lib/attestify/test.rb, line 59 def assertions_total assertions.total end
errored?()
click to toggle source
# File lib/attestify/test.rb, line 71 def errored? assertions.errored? end
failed?()
click to toggle source
# File lib/attestify/test.rb, line 75 def failed? assertions.failed? end
failed_assertions_total()
click to toggle source
# File lib/attestify/test.rb, line 63 def failed_assertions_total assertions.failed end
name()
click to toggle source
# File lib/attestify/test.rb, line 55 def name "#{self.class.name}##{@_test_method}" end
passed?()
click to toggle source
# File lib/attestify/test.rb, line 67 def passed? assertions.passed? end
result_code()
click to toggle source
# File lib/attestify/test.rb, line 79 def result_code # rubocop:disable Metrics/MethodLength if passed? "." elsif skipped? "S" elsif errored? "E" elsif failed? "F" else "?" end end
run()
click to toggle source
# File lib/attestify/test.rb, line 93 def run begin setup send @_test_method ensure teardown end rescue StandardError => e assertions.error = e ensure return self # rubocop:disable Lint/EnsureReturn end
setup()
click to toggle source
# File lib/attestify/test.rb, line 47 def setup; end
teardown()
click to toggle source
# File lib/attestify/test.rb, line 49 def teardown; end