Class RSpec::Core::ExampleGroup
In: lib/rspec/core/example_group.rb
Parent: Object

ExampleGroup and Example are the main structural elements of rspec-core. Consider this example:

    describe Thing do
      it "does something" do
      end
    end

The object returned by `describe Thing` is a subclass of ExampleGroup. The object returned by `it "does something"` is an instance of Example, which serves as a wrapper for an instance of the ExampleGroup in which it is declared.

Methods

Included Modules

Extensions::InstanceEvalWithArgs Subject::ExampleMethods Pending Let

External Aliases

description -> display_name
described_class -> describes
  @private
define_example_method -> alias_example_to
define_nested_shared_group_method -> alias_it_should_behave_like_to
describe -> context

Attributes

example  [RW]  @attr_reader Returns the [Example](Example) object that wraps this instance of `ExampleGroup`

Public Class methods

@private

@private

Generates a subclass of this example group which inherits everything except the examples themselves.

## Examples

    describe "something" do # << This describe method is defined in
                            # << RSpec::Core::DSL, included in the
                            # << global namespace
      before do
        do_something_before
      end

      let(:thing) { Thing.new }

      describe "attribute (of something)" do
        # examples in the group get the before hook
        # declared above, and can access `thing`
      end
    end

@see DSL#describe

@private

Includes shared content declared with `name`.

@see SharedExampleGroup

Includes shared content declared with `name`.

@see SharedExampleGroup

The [Metadata](Metadata) object associated with this group. @see Metadata

@private

Runs all the examples in this group

@private @return [Metadata] belonging to the parent of a nested [ExampleGroup](ExampleGroup)

@private

Public Instance methods

Returns the class or module passed to the `describe` method (or alias). Returns nil if the subject is not a class or module. @example

    describe Thing do
      it "does something" do
        described_class == Thing
      end
    end

@private instance_evals the block, capturing and reporting an exception if raised

@deprecated use [example](ExampleGroup#example-instance_method)

[Validate]