Class: Ruptr::TestElement
- Inherits:
-
Object
- Object
- Ruptr::TestElement
- Defined in:
- lib/ruptr/suite.rb,
lib/ruptr/runner.rb
Constant Summary collapse
- DEFAULT_TAGS =
{}.freeze
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#label ⇒ Object
Returns the value of attribute label.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #block? ⇒ Boolean
- #description ⇒ Object
- #each_parent_and_self {|_self| ... } ⇒ Object
-
#initialize(label = nil, identifier: label, tags: DEFAULT_TAGS, &block) ⇒ TestElement
constructor
A new instance of TestElement.
- #initialize_dup(_) ⇒ Object
- #make_result(context) ⇒ Object
- #orphan? ⇒ Boolean
- #orphanize! ⇒ Object
- #path_identifiers ⇒ Object
- #path_labels ⇒ Object
- #reparent!(new_parent) ⇒ Object
- #test_case? ⇒ Boolean
- #test_group? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(label = nil, identifier: label, tags: DEFAULT_TAGS, &block) ⇒ TestElement
Returns a new instance of TestElement.
7 8 9 10 11 12 13 |
# File 'lib/ruptr/suite.rb', line 7 def initialize(label = nil, identifier: label, tags: DEFAULT_TAGS, &block) @parent = nil @label = label @identifier = identifier @tags = @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
15 16 17 |
# File 'lib/ruptr/suite.rb', line 15 def block @block end |
#identifier ⇒ Object
Returns the value of attribute identifier.
15 16 17 |
# File 'lib/ruptr/suite.rb', line 15 def identifier @identifier end |
#label ⇒ Object
Returns the value of attribute label.
15 16 17 |
# File 'lib/ruptr/suite.rb', line 15 def label @label end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
17 18 19 |
# File 'lib/ruptr/suite.rb', line 17 def parent @parent end |
#tags ⇒ Object
Returns the value of attribute tags.
15 16 17 |
# File 'lib/ruptr/suite.rb', line 15 def @tags end |
Instance Method Details
#block? ⇒ Boolean
52 |
# File 'lib/ruptr/suite.rb', line 52 def block? = !@block.nil? |
#description ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruptr/suite.rb', line 29 def description return label.nil? ? '' : label if orphan? @description ||= if label.nil? parent.description elsif parent.description.empty? label else "#{parent.description} #{label}" end end |
#each_parent_and_self {|_self| ... } ⇒ Object
40 41 42 43 44 |
# File 'lib/ruptr/suite.rb', line 40 def each_parent_and_self(&) return to_enum __method__ unless block_given? parent.each_parent_and_self(&) unless orphan? yield self end |
#initialize_dup(_) ⇒ Object
54 55 56 57 |
# File 'lib/ruptr/suite.rb', line 54 def initialize_dup(_) super orphanize! end |
#make_result(context) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ruptr/runner.rb', line 34 def make_result(context) status = exception = user_time = system_time = nil captured_stdout, captured_stderr = maybe_capture_output(context) do user_time, system_time = Ruptr.measure_processor_time do yield rescue *Ruptr.passthrough_exceptions raise rescue SkippedExceptionMixin => exception status = :skipped rescue Exception => exception status = :failed else status = :passed end end assertions = context.assertions_count ineffective_assertions = context.ineffective_assertions_count TestResult.new(status, exception:, assertions:, ineffective_assertions:, user_time:, system_time:, captured_stdout:, captured_stderr:) end |
#orphan? ⇒ Boolean
19 |
# File 'lib/ruptr/suite.rb', line 19 def orphan? = @parent.nil? |
#orphanize! ⇒ Object
27 |
# File 'lib/ruptr/suite.rb', line 27 def orphanize! = reparent!(nil) |
#path_identifiers ⇒ Object
47 |
# File 'lib/ruptr/suite.rb', line 47 def path_identifiers = each_parent_and_self.map(&:identifier) |
#path_labels ⇒ Object
46 |
# File 'lib/ruptr/suite.rb', line 46 def path_labels = each_parent_and_self.map(&:label) |
#reparent!(new_parent) ⇒ Object
21 22 23 24 25 |
# File 'lib/ruptr/suite.rb', line 21 def reparent!(new_parent) fail "already has a parent" if new_parent && @parent @parent = new_parent @description = nil end |
#test_case? ⇒ Boolean
49 |
# File 'lib/ruptr/suite.rb', line 49 def test_case? = false |
#test_group? ⇒ Boolean
50 |
# File 'lib/ruptr/suite.rb', line 50 def test_group? = false |
#to_s ⇒ Object
59 |
# File 'lib/ruptr/suite.rb', line 59 def to_s = "#<#{self.class}: #{description.inspect}>" |