Class | Spec::Example::SharedExampleGroup
In: | lib/spec/example/shared_example_group.rb
Parent: | Module

### Methods

add_shared_example_group execute_in_class_hierarchy find_shared_example_group new shared_example_groups

### Included Modules

ExampleGroupMethods

### Public Class methods

add_shared_example_group(new_example_group)

[Source]

       # File lib/spec/example/shared_example_group.rb, line 5
    5:         def add_shared_example_group(new_example_group)
    6:           guard_against_redefining_existing_example_group(new_example_group)
    7:           shared_example_groups << new_example_group
    8:         end

find_shared_example_group(example_group_description)

[Source]

        # File lib/spec/example/shared_example_group.rb, line 10
    10:         def find_shared_example_group(example_group_description)
    11:           shared_example_groups.find do |b|
    12:             b.description == example_group_description
    13:           end
    14:         end

new(*args, &example_group_block)

[Source]

        # File lib/spec/example/shared_example_group.rb, line 39
    39:       def initialize(*args, &example_group_block)
    40:         describe(*args)
    41:         @example_group_block = example_group_block
    42:         self.class.add_shared_example_group(self)
    43:       end

shared_example_groups()

[Source]

        # File lib/spec/example/shared_example_group.rb, line 16
    16:         def shared_example_groups
    17:           # TODO - this needs to be global, or at least accessible from
    18:           # from subclasses of Example in a centralized place. I'm not loving
    19:           # this as a solution, but it works for now.
    20:           $shared_example_groups ||= []
    21:         end

### Public Instance methods

execute_in_class_hierarchy(superclass_last=false) {|example_group| ...}

[Source]

        # File lib/spec/example/shared_example_group.rb, line 49
    49:       def execute_in_class_hierarchy(superclass_last=false)
    50:         classes = [self]
    51:         superclass_last ? classes << ExampleMethods : classes.unshift(ExampleMethods)
    52:         classes.each do |example_group|
    53:           yield example_group
    54:         end
    55:       end

[Validate]