Method: Spec::DSL::Main#describe

Defined in:
lib/spec/dsl/main.rb

#describe(*args, &block) ⇒ Object Also known as: context

Creates and returns a class that includes the ExampleGroupMethods module. Which ExampleGroup type is created 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 example group classes is to have different matcher methods available from within the describe block.

See Spec::Example::ExampleGroupFactory#register for details about how to register special implementations.

[View source]

24
25
26
27
28
29
# File 'lib/spec/dsl/main.rb', line 24

def describe(*args, &block)
  raise Spec::Example::NoDescriptionError.new("example group", caller(0)[1]) if args.empty?
  add_options(args, :scope => self)
  set_location(args.options, caller(0)[1])
  Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
end