Class: RSpec::Distrib::ExampleGroup Private

Inherits:
Object
  • Object
show all
Extended by:
DelegateToMetadata
Defined in:
lib/rspec/distrib/example_group.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Objects that mimic an RSpec::Core::ExampleGroup on the Reporters.

This is necessary because the RSpec::Core::ExampleGroup is quite large and not Marshalable.

So we send this object to the Leader instead of the real ExampleGroup.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DelegateToMetadata

delegate_to_metadata

Constructor Details

#initialize(example_group, parent_example_group = nil) ⇒ ExampleGroup

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ExampleGroup.

Parameters:



30
31
32
33
34
35
36
37
# File 'lib/rspec/distrib/example_group.rb', line 30

def initialize(example_group, parent_example_group = nil)
  (example_group.)
  @class_name = example_group.name
  @parent_example_group = parent_example_group
  @children = example_group.children.map { |eg| ExampleGroup.new(eg, self) }
  @examples = example_group.filtered_examples.map { |e| ExampleResult.new(e, self) }
  @description = example_group.description
end

Instance Attribute Details

#childrenObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def children
  @children
end

#class_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def class_name
  @class_name
end

#descriptionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def description
  @description
end

#examplesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def examples
  @examples
end

#metadataObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def 
  @metadata
end

#parent_example_groupObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/distrib/example_group.rb', line 24

def parent_example_group
  @parent_example_group
end

Instance Method Details

#descendant_filtered_examplesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
# File 'lib/rspec/distrib/example_group.rb', line 43

def descendant_filtered_examples
  @descendant_filtered_examples ||= [examples, children.map(&:descendant_filtered_examples)].flatten
end

#parent_groupsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



55
56
57
58
59
60
61
62
63
64
# File 'lib/rspec/distrib/example_group.rb', line 55

def parent_groups
  groups = [self]
  current_group = self

  while (current_group = current_group.parent_example_group)
    groups << current_group
  end

  groups
end

#superclass_metadataObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/rspec/distrib/example_group.rb', line 39

def 
  parent_example_group&.
end

#top_level?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


47
48
49
# File 'lib/rspec/distrib/example_group.rb', line 47

def top_level?
  !parent_example_group
end

#top_level_descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/rspec/distrib/example_group.rb', line 51

def top_level_description
  parent_groups.last.description
end