System notice: In light of the Debian OpenSSL security issue we've regenerated the server keys. See this thread for instructions and the new key fingerprints.

Commit 57f9ef29162c10bc1438d1d41f063471fdf4c11d

rdoc tweaks

Commit diff

rspec/lib/spec/example/configuration.rb

 
77 # config.mock_with :rspec, :mocha, :flexmock, or :rr
88 # end
99 #
10 # To use any other mock framework, you'll have to provide
11 # your own adapter. This is simply a module that responds to
12 # setup_mocks_for_rspec, verify_mocks_for_rspec and teardown_mocks_for_rspec.
10 # To use any other mock framework, you'll have to provide your own
11 # adapter. This is simply a module that responds to the following
12 # methods:
13 #
14 # setup_mocks_for_rspec
15 # verify_mocks_for_rspec
16 # teardown_mocks_for_rspec.
17 #
1318 # These are your hooks into the lifecycle of a given example. RSpec will
14 # call setup_mocks_for_rspec before running anything else in each Example.
15 # After executing the #after methods, RSpec will then call verify_mocks_for_rspec
16 # and teardown_mocks_for_rspec (this is guaranteed to run even if there are
17 # failures in verify_mocks_for_rspec).
19 # call setup_mocks_for_rspec before running anything else in each
20 # Example. After executing the #after methods, RSpec will then call
21 # verify_mocks_for_rspec and teardown_mocks_for_rspec (this is
22 # guaranteed to run even if there are failures in
23 # verify_mocks_for_rspec).
1824 #
1925 # Once you've defined this module, you can pass that to mock_with:
2026 #
4141 @mock_framework ||= mock_framework_path("rspec")
4242 end
4343
44 # Declares modules to be included in all example groups (<tt>describe</tt> blocks).
45 #
46 # config.include(My::Bottle, My::Cup)
47 #
48 # If you want to restrict the inclusion to a subset of all the example groups then
49 # specify this in a Hash as the last argument:
44 # :call-seq:
45 # include(Some::Helpers)
46 # include(Some::Helpers, More::Helpers)
47 # include(My::Helpers, :type => :key)
48 #
49 # Declares modules to be included in multiple example groups
50 # (<tt>describe</tt> blocks). With no :type, the modules listed will be
51 # included in all example groups. Use :type to restrict the inclusion to
52 # a subset of example groups. The value assigned to :type should be a
53 # key that maps to a class that is either a subclass of
54 # Spec::Example::ExampleGroup or extends Spec::Example::ExampleGroupMethods
55 # and includes Spec::Example::ExampleMethods
5056 #
5157 # config.include(My::Pony, My::Horse, :type => :farm)
5258 #
8282 #
8383 # This makes it possible to say:
8484 #
85 # person.should swim # passes if person.should_swim? returns true
85 # person.should swim # passes if person.can_swim? returns true
8686 #
8787 def predicate_matchers
8888 @predicate_matchers ||= {}
9797 )
9898 example_group.prepend_before(scope, &proc)
9999 end
100
100101 # Appends a global <tt>before</tt> block to all example groups.
101102 #
102 # If you want to restrict the block to a subset of all the example groups then
103 # specify this in a Hash as the last argument:
103 # If you want to restrict the block to a subset of all the example
104 # groups then specify this in a Hash as the last argument:
104105 #
105106 # config.prepend_before(:all, :type => :farm)
106107 #
128128 example_group.prepend_after(scope, &proc)
129129 end
130130 alias_method :after, :prepend_after
131
131132 # Appends a global <tt>after</tt> block to all example groups.
132133 # See #append_before for filtering semantics.
133134 def append_after(*args, &proc)
toggle raw diff

rspec/lib/spec/example/example_group.rb

 
11module Spec
22 module Example
3 # The superclass for all regular RSpec examples.
3 # Base class for customized example groups. Use this if you
4 # want to make a custom example group.
45 class ExampleGroup
56 extend Spec::Example::ExampleGroupMethods
67 include Spec::Example::ExampleMethods
toggle raw diff

rspec/lib/spec/example/example_group_factory.rb

 
77 default(ExampleGroup)
88 end
99
10 # Registers an example group class +klass+ with the symbol
11 # +type+. For example:
10 # Registers an example group class +klass+ with the symbol +type+. For
11 # example:
1212 #
13 # Spec::Example::ExampleGroupFactory.register(:farm, Spec::Farm::Example::FarmExampleGroup)
13 # Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup)
1414 #
15 # This will cause Main#describe from a file living in
16 # <tt>spec/farm</tt> to create example group instances of type
17 # Spec::Farm::Example::FarmExampleGroup.
18 def register(id, example_group_class)
19 @example_group_types[id] = example_group_class
15 # With that you can append a hash with :type => :farm to the describe
16 # method and it will load an instance of FarmExampleGroup.
17 #
18 # describe Pig, :type => :farm do
19 # ...
20 #
21 # If you don't use the hash explicitly, <tt>describe</tt> will
22 # implicitly use an instance of FarmExampleGroup for any file loaded
23 # from the <tt>./spec/farm</tt> directory.
24 def register(key, example_group_class)
25 @example_group_types[key] = example_group_class
2026 end
2127
2228 # Sets the default ExampleGroup class
3232 @example_group_types.merge!(old) if old
3333 end
3434
35 def get(id=nil)
36 if @example_group_types.values.include?(id)
37 id
35 def get(key=nil)
36 if @example_group_types.values.include?(key)
37 key
3838 else
39 @example_group_types[id]
39 @example_group_types[key]
4040 end
4141 end
4242
4949 protected
5050
5151 def determine_superclass(opts)
52 id = if opts[:type]
52 key = if opts[:type]
5353 opts[:type]
5454 elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/
5555 $2 == '' ? nil : $2.to_sym
5656 end
57 get(id)
57 get(key)
5858 end
5959
6060 end
toggle raw diff