Parent

Class Index [+]

Quicksearch

Spec::Runner::Configuration

Public Instance Methods

after(scope = :each, options={}, &proc) click to toggle source
Alias for: prepend_after
append_after(scope = :each, options={}, &proc) click to toggle source

Appends a global after block to all example groups.

See append_before for scoping semantics.

     # File lib/spec/runner/configuration.rb, line 123
123:       def append_after(scope = :each, options={}, &proc)
124:         add_callback(:append_after, scope, options, &proc)
125:       end
append_before(scope = :each, options={}, &proc) click to toggle source

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.

     # File lib/spec/runner/configuration.rb, line 100
100:       def append_before(scope = :each, options={}, &proc)
101:         add_callback(:append_before, scope, options, &proc)
102:       end
Also aliased as: before
before(scope = :each, options={}, &proc) click to toggle source
Alias for: append_before
extend(Some::Helpers) extend(Some::Helpers, More::Helpers) extend(My::Helpers, :type => :key) click to toggle source

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

    # File lib/spec/runner/configuration.rb, line 90
90:       def extend(*modules_and_options)
91:         include_or_extend(:extend, *modules_and_options)
92:       end
ignore_backtrace_patterns(*patterns) click to toggle source

Adds patterns to the list of patterns ignored in the backtrace when a failure is output by rspec. Example:

  config.ignore_backtrace_patterns /spork/, /shoulda/, "/some/weird/path/"

When quiet backtraces are turned on (default), this will exclude any lines that match any of the Regexps and Strings passed.

     # File lib/spec/runner/configuration.rb, line 149
149:       def ignore_backtrace_patterns(*patterns)
150:         @ignored_backtrace_patterns ||= []
151:         @ignored_backtrace_patterns += patterns
152:       end
include(Some::Helpers) include(Some::Helpers, More::Helpers) include(My::Helpers, :type => :key) click to toggle source

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 79
79:       def include(*modules_and_options)
80:         include_or_extend(:include, *modules_and_options)
81:       end
mock_with(mock_framework) click to toggle source

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 # 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
    # File lib/spec/runner/configuration.rb, line 33
33:       def mock_with(mock_framework)
34:         @mock_framework = case mock_framework
35:         when Symbol
36:           mock_framework_path(mock_framework.to_s)
37:         else
38:           mock_framework
39:         end
40:       end
predicate_matchers() click to toggle source

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
     # File lib/spec/runner/configuration.rb, line 137
137:       def predicate_matchers
138:         @predicate_matchers ||= Spec::HashWithDeprecationNotice.new("predicate_matchers", "the new Matcher DSL")
139:       end
prepend_after(scope = :each, options={}, &proc) click to toggle source

Prepends a global after block to all example groups.

See append_before for scoping semantics.

     # File lib/spec/runner/configuration.rb, line 115
115:       def prepend_after(scope = :each, options={}, &proc)
116:         add_callback(:prepend_after, scope, options, &proc)
117:       end
Also aliased as: after
prepend_before(scope = :each, options={}, &proc) click to toggle source

Prepends a global before block to all example groups.

See append_before for scoping semantics.

     # File lib/spec/runner/configuration.rb, line 108
108:       def prepend_before(scope = :each, options={}, &proc)
109:         add_callback(:prepend_before, scope, options, &proc)
110:       end

Private Instance Methods

add_callback(sym, *args, &proc) click to toggle source
     # File lib/spec/runner/configuration.rb, line 170
170:       def add_callback(sym, *args, &proc)
171:         scope, options = scope_and_options(*args)
172:         example_group = Spec::Example::ExampleGroupFactory[get_type_from_options(options)]
173:         example_group.__send__(sym, scope, &proc)
174:       end
get_type_from_options(options) click to toggle source
     # File lib/spec/runner/configuration.rb, line 176
176:       def get_type_from_options(options)
177:         options[:type] || options[:behaviour_type]
178:       end
include_or_extend(action, *args) click to toggle source
     # File lib/spec/runner/configuration.rb, line 160
160:       def include_or_extend(action, *args)
161:         modules, options = args_and_options(*args)
162:         [get_type_from_options(options)].flatten.each do |required_example_group|
163:           required_example_group = required_example_group.to_sym if required_example_group
164:           modules.each do |mod|
165:             Spec::Example::ExampleGroupFactory[required_example_group].__send__(action, mod)
166:           end
167:         end
168:       end
mock_framework_path(framework_name) click to toggle source
     # File lib/spec/runner/configuration.rb, line 180
180:       def mock_framework_path(framework_name)
181:         "spec/adapters/mock_frameworks/#{framework_name}"
182:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.