3
class ExampleGroupFactory
6
@example_group_types = nil
10
# Registers an example group class +klass+ with the symbol
11
# +type+. For example:
13
# Spec::Example::ExampleGroupFactory.register(:farm, Spec::Farm::Example::FarmExampleGroup)
15
# This will cause Main#describe from a file living in
16
# <tt>spec/farm</tt> to create example group instances of type
17
# Spec::Farm::Example::FarmExampleGroup.
18
def register(id, example_group_class)
19
@example_group_types[id] = example_group_class
22
# Sets the default ExampleGroup class
23
def default(example_group_class)
24
old = @example_group_types
25
@example_group_types = Hash.new(example_group_class)
26
@example_group_types.merge(old) if old
30
if @example_group_types.values.include?(id)
33
@example_group_types[id]
37
def create_example_group(*args, &block)
38
opts = Hash === args.last ? args.last : {}
40
SharedExampleGroup.new(*args, &block)
42
superclass = determine_superclass(opts)
43
superclass.describe(*args, &block)
49
def determine_superclass(opts)
52
elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/
53
$2 == '' ? nil : $2.to_sym