| Class | Spec::Example::ExampleGroupFactory |
| In: |
lib/spec/example/example_group_factory.rb
|
| Parent: | Object |
# File lib/spec/example/example_group_factory.rb, line 43
43: def create_example_group(*args, &block)
44: opts = Hash === args.last ? args.last : {}
45: superclass = determine_superclass(opts)
46: superclass.describe(*args, &block)
47: end
Sets the default ExampleGroup class
# File lib/spec/example/example_group_factory.rb, line 29
29: def default(example_group_class)
30: old = @example_group_types
31: @example_group_types = Hash.new(example_group_class)
32: @example_group_types.merge!(old) if old
33: end
# File lib/spec/example/example_group_factory.rb, line 35
35: def get(key=nil)
36: if @example_group_types.values.include?(key)
37: key
38: else
39: @example_group_types[key]
40: end
41: end
Registers an example group class klass with the symbol type. For example:
Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup)
With that you can append a hash with :type => :farm to the describe method and it will load an instance of FarmExampleGroup.
describe Pig, :type => :farm do
...
If you don‘t use the hash explicitly, describe will implicitly use an instance of FarmExampleGroup for any file loaded from the ./spec/farm directory.
# File lib/spec/example/example_group_factory.rb, line 24
24: def register(key, example_group_class)
25: @example_group_types[key] = example_group_class
26: end
# File lib/spec/example/example_group_factory.rb, line 5 5: def reset 6: @example_group_types = nil 7: default(ExampleGroup) 8: end