Class: Spec::Example::ExampleGroupFactory
- Defined in:
- lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb
Class Method Summary collapse
- .all_registered?(example_group_classes) ⇒ Boolean
- .create_example_group(*args, &block) ⇒ Object
-
.default(example_group_class) ⇒ Object
Sets the default ExampleGroup class.
- .get(key = nil) ⇒ Object
-
.register(key, example_group_class) ⇒ Object
Registers an example group class
klass
with the symboltype
. - .reset ⇒ Object
Class Method Details
.all_registered?(example_group_classes) ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 10 def all_registered?(example_group_classes) example_group_classes.each do |example_group_class| return false unless registered_or_ancestor_of_registered? example_group_class end return true end |
.create_example_group(*args, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 50 def create_example_group(*args, &block) opts = Hash === args.last ? args.last : {} superclass = determine_superclass(opts) superclass.describe(*args, &block) end |
.default(example_group_class) ⇒ Object
Sets the default ExampleGroup class
36 37 38 39 40 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 36 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 |
.get(key = nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 42 def get(key=nil) if @example_group_types.values.include?(key) key else @example_group_types[key] end end |
.register(key, example_group_class) ⇒ Object
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.
31 32 33 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 31 def register(key, example_group_class) @example_group_types[key] = example_group_class end |
.reset ⇒ Object
5 6 7 8 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb', line 5 def reset @example_group_types = nil default(ExampleGroup) end |