Class Spec::DSL::Configuration
In: lib/spec/dsl/configuration.rb
Parent: Object

Methods

Public Instance methods

after(*args, &proc)

Alias for prepend_after

Appends a global after block to all behaviours. See append_before for filtering semantics.

[Source]

     # File lib/spec/dsl/configuration.rb, line 123
123:       def append_after(*args, &proc)
124:         Behaviour.append_after(*args, &proc)
125:       end

Appends a global before block to all behaviours.

If you want to restrict the block to a subset of all the behaviours then specify this in a Hash as the last argument:

  config.prepend_before(:all, :behaviour_type => :farm)

or

  config.prepend_before(:behaviour_type => :farm)

[Source]

     # File lib/spec/dsl/configuration.rb, line 110
110:       def append_before(*args, &proc)
111:         Behaviour.append_before(*args, &proc)
112:       end
before(*args, &proc)

Alias for append_before

Declares modules to be included in all behaviours (describe blocks).

  config.include(My::Bottle, My::Cup)

If you want to restrict the inclusion to a subset of all the behaviours then specify this in a Hash as the last argument:

  config.include(My::Pony, My::Horse, :behaviour_type => :farm)

Only behaviours that have that type will get the modules included:

  describe "Downtown", :behaviour_type => :city do
    # Will *not* get My::Pony and My::Horse included
  end

  describe "Old Mac Donald", :behaviour_type => :farm do
    # *Will* get My::Pony and My::Horse included
  end

[Source]

    # File lib/spec/dsl/configuration.rb, line 58
58:       def include(*args)
59:         args << {} unless Hash === args.last
60:         modules, options = args_and_options(*args)
61:         required_behaviour_type = options[:behaviour_type]
62:         required_behaviour_type = required_behaviour_type.to_sym unless required_behaviour_type.nil?
63:         @modules ||= {}
64:         @modules[required_behaviour_type] ||= []
65:         @modules[required_behaviour_type] += modules
66:       end

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 setup_mocks_for_rspec, verify_mocks_for_rspec and 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

[Source]

    # File lib/spec/dsl/configuration.rb, line 26
26:       def mock_with(mock_framework)
27:         @mock_framework = case mock_framework
28:         when Symbol
29:           mock_framework_path(mock_framework.to_s)
30:         else
31:           mock_framework
32:         end
33:       end

Defines global predicate matchers. Example:

  config.predicate_matchers[:swim] = :can_swim?

This makes it possible to say:

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

[Source]

    # File lib/spec/dsl/configuration.rb, line 90
90:       def predicate_matchers
91:         @predicate_matchers ||= {}
92:       end

Prepends a global after block to all behaviours. See append_before for filtering semantics.

[Source]

     # File lib/spec/dsl/configuration.rb, line 117
117:       def prepend_after(*args, &proc)
118:         Behaviour.prepend_after(*args, &proc)
119:       end

Prepends a global before block to all behaviours. See append_before for filtering semantics.

[Source]

    # File lib/spec/dsl/configuration.rb, line 96
96:       def prepend_before(*args, &proc)
97:         Behaviour.prepend_before(*args, &proc)
98:       end

[Validate]