Module: Kernel
- Defined in:
- lib/spec/runner/extensions/kernel.rb
Instance Method Summary collapse
-
#describe(*args, &block) ⇒ Object
(also: #context)
Creates and registers an instance of a Spec::DSL::Behaviour (or a subclass).
- #respond_to(*names) ⇒ Object
Instance Method Details
#describe(*args, &block) ⇒ Object Also known as: context
Creates and registers an instance of a Spec::DSL::Behaviour (or a subclass). The instantiated behaviour 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 behaviour class with an options Hash as the last argument:
describe "name", :behaviour_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::DSL::BehaviourFactory#add_behaviour_class for details about how to register special Spec::DSL::Behaviour implementations.
20 21 22 23 24 25 |
# File 'lib/spec/runner/extensions/kernel.rb', line 20 def describe(*args, &block) raise ArgumentError if args.empty? args << {} unless Hash === args.last args.last[:spec_path] = caller(0)[1] register_behaviour(Spec::DSL::BehaviourFactory.create(*args, &block)) end |