5 # Chooses what mock framework to use. Example:
7 # Spec::Runner.configure do |config|
8 # config.mock_with :rspec # or :mocha, or :flexmock
11 # To use any other mock framework, you'll have to provide
12 # your own adapter. This is simply a module that responds to
13 # setup_mocks_for_rspec, verify_mocks_for_rspec and teardown_mocks_for_rspec.
14 # These are your hooks into the lifecycle of a given example. RSpec will
15 # call setup_mocks_for_rspec before running anything else in each Example.
16 # After executing the #after methods, RSpec will then call verify_mocks_for_rspec
17 # and teardown_mocks_for_rspec (this is guaranteed to run even if there are
18 # failures in verify_mocks_for_rspec).
20 # Once you've defined this module, you can pass that to mock_with:
22 # Spec::Runner.configure do |config|
23 # config.mock_with MyMockFrameworkAdapter
26 def mock_with(mock_framework)
27 @mock_framework = case mock_framework
29 mock_framework_path(mock_framework.to_s)
35 def mock_framework # :nodoc:
36 @mock_framework ||= mock_framework_path("rspec")
39 # Declares modules to be included in all behaviours (<tt>describe</tt> blocks).
41 # config.include(My::Bottle, My::Cup)
43 # If you want to restrict the inclusion to a subset of all the behaviours then
44 # specify this in a Hash as the last argument:
46 # config.include(My::Pony, My::Horse, :behaviour_type => :farm)
48 # Only behaviours that have that type will get the modules included:
50 # describe "Downtown", :behaviour_type => :city do
51 # # Will *not* get My::Pony and My::Horse included
54 # describe "Old Mac Donald", :behaviour_type => :farm do
55 # # *Will* get My::Pony and My::Horse included
59 included_modules.push(*args)
62 def included_modules # :nodoc:
63 @included_modules ||= []
66 # Defines global predicate matchers. Example:
68 # config.predicate_matchers[:swim] = :can_swim?
70 # This makes it possible to say:
72 # person.should swim # passes if person.should_swim? returns true
74 def predicate_matchers
75 @predicate_matchers ||= {}
78 # Prepends a global <tt>before</tt> block to all behaviours.
79 # See #append_before for filtering semantics.
80 def prepend_before(*args, &proc)
81 Behaviour.prepend_before(*args, &proc)
83 # Appends a global <tt>before</tt> block to all behaviours.
85 # If you want to restrict the block to a subset of all the behaviours then
86 # specify this in a Hash as the last argument:
88 # config.prepend_before(:all, :behaviour_type => :farm)
92 # config.prepend_before(:behaviour_type => :farm)
94 def append_before(*args, &proc)
95 Behaviour.append_before(*args, &proc)
97 alias_method :before, :append_before
99 # Prepends a global <tt>after</tt> block to all behaviours.
100 # See #append_before for filtering semantics.
101 def prepend_after(*args, &proc)
102 Behaviour.prepend_after(*args, &proc)
104 alias_method :after, :prepend_after
105 # Appends a global <tt>after</tt> block to all behaviours.
106 # See #append_before for filtering semantics.
107 def append_after(*args, &proc)
108 Behaviour.append_after(*args, &proc)
113 def mock_framework_path(framework_name)
114 File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "plugins", "mock_frameworks", framework_name))