class Spec::Example::ExampleGroupFactory
def create_example_group(*args, &block)
def create_example_group(*args, &block) opts = Hash === args.last ? args.last : {} superclass = determine_superclass(opts) superclass.describe(*args, &block) end
def default(example_group_class)
def default(example_group_class) old = @example_group_types @example_group_types = Hash.new(example_group_class) @example_group_types.merge!(old) if old end
def determine_superclass(opts)
def determine_superclass(opts) key = if opts[:type] opts[:type] elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/ $2 == '' ? nil : $2.to_sym end get(key) end
def get(key=nil)
def get(key=nil) if @example_group_types.values.include?(key) key else @example_group_types[key] end end
def register(key, example_group_class)
implicitly use an instance of FarmExampleGroup for any file loaded
If you don't use the hash explicitly, describe will
...
describe Pig, :type => :farm do
method and it will load an instance of FarmExampleGroup.
With that you can append a hash with :type => :farm to the describe
Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup)
example:
Registers an example group class +klass+ with the symbol +type+. For
def register(key, example_group_class) @example_group_types[key] = example_group_class end
def reset
def reset @example_group_types = nil default(ExampleGroup) end