Class Index [+]

Quicksearch

Spec::Example::ExampleGroupFactory::ClassMethods

Public Instance Methods

[](key) click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 61
61:         def [](key)
62:           @example_group_types[key]
63:         end
create_example_group(*args, &block) click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 27
27:         def create_example_group(*args, &block)
28:           raise ArgumentError if args.empty? || block.nil?
29:           add_options(args)
30:           superclass = determine_superclass(args.last)
31:           superclass.describe(*args, &block)
32:         end
default(example_group_class) click to toggle source

Sets the default ExampleGroup class

    # File lib/spec/example/example_group_factory.rb, line 53
53:         def default(example_group_class)
54:           Spec.__send__ :remove_const, :ExampleGroup if Spec.const_defined?(:ExampleGroup)
55:           Spec.const_set(:ExampleGroup, example_group_class)
56:           old = @example_group_types
57:           @example_group_types = Hash.new(example_group_class)
58:           @example_group_types.merge!(old) if old
59:         end
example_group_creation_listeners() click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 13
13:         def example_group_creation_listeners
14:           @example_group_creation_listeners ||= []
15:         end
register(key, example_group_class) click to toggle source

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 48
48:         def register(key, example_group_class)
49:           @example_group_types[key.to_sym] = example_group_class
50:         end
register_example_group(klass) click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 17
17:         def register_example_group(klass)
18:           example_group_creation_listeners.each do |listener|
19:             listener.register_example_group(klass)
20:           end
21:         end
reset() click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 8
 8:         def reset
 9:           @example_group_types = nil
10:           default(ExampleGroup)
11:         end

Protected Instance Methods

determine_superclass(opts) click to toggle source
    # File lib/spec/example/example_group_factory.rb, line 67
67:         def determine_superclass(opts)
68:           if type = opts[:type]
69:             self[type]
70:           elsif opts[:location] =~ /spec(\\|\/)(#{@example_group_types.keys.sort_by{|k| k.to_s.length}.reverse.join('|')})/
71:             self[$2 == '' ? nil : $2.to_sym]
72:           else
73:             self[nil]
74:           end
75:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.