Module | Spec::Extensions::Main |
In: |
lib/spec/extensions/main.rb
|
Creates and returns a class that includes the ExampleGroupMethods module. The ExampleGroup sub-class depends on the directory of the file calling this method. For example, Spec::Rails will use different classes for specs living in spec/models, spec/helpers, spec/views and spec/controllers.
It is also possible to override autodiscovery of the example group type with an options Hash as the last argument:
describe "name", :type => :something_special do ...
The reason for using different behaviour classes is to have different matcher methods available from within the describe block.
See Spec::Example::ExampleFactory#register for details about how to register special implementations.
# File lib/spec/extensions/main.rb, line 22 22: def describe(*args, &block) 23: raise ArgumentError if args.empty? 24: raise ArgumentError unless block 25: args << {} unless Hash === args.last 26: args.last[:spec_path] = caller(0)[1] 27: Spec::Example::ExampleGroupFactory.create_example_group(*args, &block) 28: end