Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/configuration.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/configuration.rb 194 76
77.32%
42.11%

Key

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.

Coverage Details

1 module Spec
2   module Runner
3     class Configuration
4       include Spec::Example::ArgsAndOptions
5       
6       # Chooses what mock framework to use. Example:
7       #
8       #   Spec::Runner.configure do |config|
9       #     config.mock_with :rspec, :mocha, :flexmock, or :rr
10       #   end
11       #
12       # To use any other mock framework, you'll have to provide your own
13       # adapter. This is simply a module that responds to the following
14       # methods:
15       #
16       #   setup_mocks_for_rspec
17       #   verify_mocks_for_rspec
18       #   teardown_mocks_for_rspec.
19       #
20       # These are your hooks into the lifecycle of a given example. RSpec will
21       # call setup_mocks_for_rspec before running anything else in each
22       # Example. After executing the #after methods, RSpec will then call
23       # verify_mocks_for_rspec and teardown_mocks_for_rspec (this is
24       # guaranteed to run even if there are failures in
25       # verify_mocks_for_rspec).
26       #
27       # Once you've defined this module, you can pass that to mock_with:
28       #
29       #   Spec::Runner.configure do |config|
30       #     config.mock_with MyMockFrameworkAdapter
31       #   end
32       #
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
41       
42       def mock_framework # :nodoc:
43         @mock_framework ||= mock_framework_path("rspec")
44       end
45       
46       # :call-seq:
47       #   include(Some::Helpers)
48       #   include(Some::Helpers, More::Helpers)
49       #   include(My::Helpers, :type => :key)
50       #
51       # Declares modules to be included in multiple example groups
52       # (<tt>describe</tt> blocks). With no <tt>:type</tt>, the modules listed
53       # will be included in all example groups.
54       #
55       # Use <tt>:type</tt> to restrict
56       # the inclusion to a subset of example groups. The value assigned to
57       # <tt>:type</tt> should be a key that maps to a class that is either a
58       # subclass of Spec::Example::ExampleGroup or extends
59       # Spec::Example::ExampleGroupMethods and includes
60       # Spec::Example::ExampleMethods.
61       #
62       # For example, the rspec-rails gem/plugin extends Test::Unit::TestCase
63       # with Spec::Example::ExampleGroupMethods and includes
64       # Spec::Example::ExampleMethods in it. So if you have a module of helper
65       # methods for controller examples, you could do this:
66       #
67       #   config.include(ControllerExampleHelpers, :type => :controller)
68       #
69       # Only example groups that have that type will get the modules included:
70       #
71       #   describe Account, :type => :model do
72       #     # Will *not* include ControllerExampleHelpers
73       #   end
74       #
75       #   describe AccountsController, :type => :controller do
76       #     # *Will* include ControllerExampleHelpers
77       #   end
78       #
79       def include(*modules_and_options)
80         include_or_extend(:include, *modules_and_options)
81       end
82       
83       # :call-seq:
84       #   extend(Some::Helpers)
85       #   extend(Some::Helpers, More::Helpers)
86       #   extend(My::Helpers, :type => :key)
87       #
88       # Works just like #include, but extends the example groups
89       # with the modules rather than including them.
90       def extend(*modules_and_options)
91         include_or_extend(:extend, *modules_and_options)
92       end
93       
94       # Appends a global <tt>before</tt> block to all example groups.
95       # <tt>scope</tt> can be any of <tt>:each</tt> (default), <tt>:all</tt>, or
96       # <tt>:suite</tt>. When <tt>:each</tt>, the block is executed before each
97       # example. When <tt>:all</tt>, the block is executed once per example
98       # group, before any of its examples are run. When <tt>:suite</tt> the
99       # block is run once before the entire suite is run.
100       def append_before(scope = :each, options={}, &proc)
101         add_callback(:append_before, scope, options, &proc)
102       end
103       alias_method :before, :append_before
104 
105       # Prepends a global <tt>before</tt> block to all example groups.
106       # 
107       # See <tt>append_before</tt> for scoping semantics.
108       def prepend_before(scope = :each, options={}, &proc)
109         add_callback(:prepend_before, scope, options, &proc)
110       end
111       
112       # Prepends a global <tt>after</tt> block to all example groups.
113       # 
114       # See <tt>append_before</tt> for scoping semantics.
115       def prepend_after(scope = :each, options={}, &proc)
116         add_callback(:prepend_after, scope, options, &proc)
117       end
118       alias_method :after, :prepend_after
119       
120       # Appends a global <tt>after</tt> block to all example groups.
121       # 
122       # See <tt>append_before</tt> for scoping semantics.
123       def append_after(scope = :each, options={}, &proc)
124         add_callback(:append_after, scope, options, &proc)
125       end
126 
127       # DEPRECATED - use Spec::Matchers::DSL instead
128       #
129       # Defines global predicate matchers. Example:
130       #
131       #   config.predicate_matchers[:swim] = :can_swim?
132       #
133       # This makes it possible to say:
134       #
135       #   person.should swim # passes if person.can_swim? returns true
136       #
137       def predicate_matchers
138         @predicate_matchers ||= Spec::HashWithDeprecationNotice.new("predicate_matchers", "the new Matcher DSL")
139       end
140 
141       # Adds patterns to the list of patterns ignored in the backtrace when a
142       # failure is output by rspec. Example:
143       #
144       #   config.ignore_backtrace_patterns /spork/, /shoulda/, "/some/weird/path/"
145       #
146       # When quiet backtraces are turned on (default), this will exclude any
147       # lines that match any of the Regexps and Strings passed.
148       #
149       def ignore_backtrace_patterns(*patterns)
150         @ignored_backtrace_patterns ||= []
151         @ignored_backtrace_patterns += patterns
152       end
153 
154       def ignored_backtrace_patterns # :nodoc:
155         @ignored_backtrace_patterns ||= []
156       end
157       
158     private
159     
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
169 
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
175 
176       def get_type_from_options(options)
177         options[:type] || options[:behaviour_type]
178       end
179     
180       def mock_framework_path(framework_name)
181         "spec/adapters/mock_frameworks/#{framework_name}"
182       end
183 
184       def scope_and_options(*args) # :nodoc:
185         args, options = args_and_options(*args)
186         return scope_from(*args), options
187       end
188 
189       def scope_from(*args) # :nodoc:
190         args[0] || :each
191       end
192     end
193   end
194 end

Generated on Mon May 10 23:40:28 -0700 2010 with rcov 0.9.8