Method: Spec::Runner::Configuration#include
- Defined in:
- lib/spec/runner/configuration.rb
#include(*modules_and_options) ⇒ Object
:call-seq:
include(Some::Helpers)
include(Some::Helpers, More::Helpers)
include(My::Helpers, :type => :key)
Declares modules to be included in multiple example groups (describe blocks). With no :type, the modules listed will be included in all example groups.
Use :type to restrict the inclusion to a subset of example groups. The value assigned to :type should be a key that maps to a class that is either a subclass of Spec::Example::ExampleGroup or extends Spec::Example::ExampleGroupMethods and includes Spec::Example::ExampleMethods.
For example, the rspec-rails gem/plugin extends Test::Unit::TestCase with Spec::Example::ExampleGroupMethods and includes Spec::Example::ExampleMethods in it. So if you have a module of helper methods for controller examples, you could do this:
config.include(ControllerExampleHelpers, :type => :controller)
Only example groups that have that type will get the modules included:
describe Account, :type => :model do
# Will *not* include ControllerExampleHelpers
end
describe AccountsController, :type => :controller do
# *Will* include ControllerExampleHelpers
end
79 80 81 |
# File 'lib/spec/runner/configuration.rb', line 79 def include(*) include_or_extend(:include, *) end |