Class: Spec::Runner::Configuration

Class | Spec::Runner::Configuration
In: | lib/spec/runner/configuration.rb
Parent: | Object

### Methods

after append_after append_before before extend include mock_with predicate_matchers prepend_after prepend_before

### Included Modules

Spec::Example::ArgsAndOptions

### Public Instance methods

after(scope = :each, options={}, &proc)

Alias for prepend_after

append_after(scope = :each, options={}, &proc)

Appends a global `after` block to all example groups.

See `append_before` for scoping semantics.

append_before(scope = :each, options={}, &proc)

Appends a global `before` block to all example groups. `scope` can be any of `:each` (default), `:all`, or `:suite`. When `:each`, the block is executed before each example. When `:all`, the block is executed once per example group, before any of its examples are run. When `:suite` the block is run once before the entire suite is run.

before(scope = :each, options={}, &proc)

Alias for append_before

extend(Some::Helpers)
extend(Some::Helpers, More::Helpers)
extend(My::Helpers, :type => :key)

Works just like include, but extends the example groups with the modules rather than including them.

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

mock_with(mock_framework)

Chooses what mock framework to use. Example:

      Spec::Runner.configure do |config|
        config.mock_with :rspec, :mocha, :flexmock, or :rr
      end

To use any other mock framework, you‘ll have to provide your own adapter. This is simply a module that responds to the following methods:

      setup_mocks_for_rspec
      verify_mocks_for_rspec
      teardown_mocks_for_rspec.

These are your hooks into the lifecycle of a given example. RSpec will call setup_mocks_for_rspec before running anything else in each Example. After executing the after methods, RSpec will then call verify_mocks_for_rspec and teardown_mocks_for_rspec (this is guaranteed to run even if there are failures in verify_mocks_for_rspec).

Once you‘ve defined this module, you can pass that to mock_with:

      Spec::Runner.configure do |config|
        config.mock_with MyMockFrameworkAdapter
      end

predicate_matchers()

DEPRECATED - use Spec::Matchers::DSL instead

Defines global predicate matchers. Example:

      config.predicate_matchers[:swim] = :can_swim?

This makes it possible to say:

      person.should swim # passes if person.can_swim? returns true

prepend_after(scope = :each, options={}, &proc)

Prepends a global `after` block to all example groups.

See `append_before` for scoping semantics.

prepend_before(scope = :each, options={}, &proc)

Prepends a global `before` block to all example groups.

See `append_before` for scoping semantics.

[Validate]