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
# File lib/spec/runner/configuration.rb, line 77 def include(*args) include_or_extend(:include, *args) end