C0 code coverage information
Generated on Mon Aug 13 01:18:53 -0400 2007 with rcov 0.8.0
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 module Spec
2 module DSL
3 class Configuration
4
5 # Chooses what mock framework to use. Example:
6 #
7 # Spec::Runner.configure do |config|
8 # config.mock_with :rspec, :mocha, :flexmock, or :rr
9 # end
10 #
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).
19 #
20 # Once you've defined this module, you can pass that to mock_with:
21 #
22 # Spec::Runner.configure do |config|
23 # config.mock_with MyMockFrameworkAdapter
24 # end
25 #
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
34
35 def mock_framework # :nodoc:
36 @mock_framework ||= mock_framework_path("rspec")
37 end
38
39 # Declares modules to be included in all behaviours (<tt>describe</tt> blocks).
40 #
41 # config.include(My::Bottle, My::Cup)
42 #
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:
45 #
46 # config.include(My::Pony, My::Horse, :behaviour_type => :farm)
47 #
48 # Only behaviours that have that type will get the modules included:
49 #
50 # describe "Downtown", :behaviour_type => :city do
51 # # Will *not* get My::Pony and My::Horse included
52 # end
53 #
54 # describe "Old Mac Donald", :behaviour_type => :farm do
55 # # *Will* get My::Pony and My::Horse included
56 # end
57 #
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
67
68 def modules_for(required_behaviour_type) #:nodoc:
69 @modules ||= {}
70 modules = @modules[nil] || [] # general ones
71 modules << @modules[required_behaviour_type.to_sym] unless required_behaviour_type.nil?
72 modules.uniq.compact
73 end
74
75 # This is just for cleanup in RSpec's own examples
76 def exclude(*modules) #:nodoc:
77 @modules.each do |behaviour_type, mods|
78 modules.each{|m| mods.delete(m)}
79 end
80 end
81
82 # Defines global predicate matchers. Example:
83 #
84 # config.predicate_matchers[:swim] = :can_swim?
85 #
86 # This makes it possible to say:
87 #
88 # person.should swim # passes if person.should_swim? returns true
89 #
90 def predicate_matchers
91 @predicate_matchers ||= {}
92 end
93
94 # Prepends a global <tt>before</tt> block to all behaviours.
95 # See #append_before for filtering semantics.
96 def prepend_before(*args, &proc)
97 Behaviour.prepend_before(*args, &proc)
98 end
99 # Appends a global <tt>before</tt> block to all behaviours.
100 #
101 # If you want to restrict the block to a subset of all the behaviours then
102 # specify this in a Hash as the last argument:
103 #
104 # config.prepend_before(:all, :behaviour_type => :farm)
105 #
106 # or
107 #
108 # config.prepend_before(:behaviour_type => :farm)
109 #
110 def append_before(*args, &proc)
111 Behaviour.append_before(*args, &proc)
112 end
113 alias_method :before, :append_before
114
115 # Prepends a global <tt>after</tt> block to all behaviours.
116 # See #append_before for filtering semantics.
117 def prepend_after(*args, &proc)
118 Behaviour.prepend_after(*args, &proc)
119 end
120 alias_method :after, :prepend_after
121 # Appends a global <tt>after</tt> block to all behaviours.
122 # See #append_before for filtering semantics.
123 def append_after(*args, &proc)
124 Behaviour.append_after(*args, &proc)
125 end
126
127 private
128
129 def mock_framework_path(framework_name)
130 File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "plugins", "mock_frameworks", framework_name))
131 end
132
133 end
134 end
135 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.