Module: RSpec::Core::SharedExampleGroup

### Home Classes Methods

### In Files

- lib/rspec/core/shared_example_group.rb
- lib/rspec/core/shared_example_group/collection.rb

### Namespace

- MODULE RSpec::Core::SharedExampleGroup::TopLevelDSL
- CLASS RSpec::Core::SharedExampleGroup::Collection
- CLASS RSpec::Core::SharedExampleGroup::Registry

### Methods

- ::registry
- #share_as
- #share_examples_for
- #shared_context
- #shared_example_groups
- #shared_examples
- #shared_examples_for

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# RSpec::Core::SharedExampleGroup

### Public Class Methods

registry() click to toggle source

    # File lib/rspec/core/shared_example_group.rb, line 70
    def self.registry
      @registry ||= Registry.new
    end

### Public Instance Methods

share_as(name, &block) click to toggle source

@deprecated

    # File lib/rspec/core/shared_example_group.rb, line 40
    def share_as(name, &block)
      RSpec.deprecate("Rspec::Core::SharedExampleGroup#share_as",
                      :replacement => "RSpec::SharedContext or shared_examples")
      SharedExampleGroup.registry.add_const(self, name, &block)
    end

share_examples_for(*args, &block) click to toggle source
Alias for: shared_examples
shared_context(*args, &block) click to toggle source
Alias for: shared_examples
shared_example_groups() click to toggle source

    # File lib/rspec/core/shared_example_group.rb, line 46
    def shared_example_groups
      SharedExampleGroup.registry.shared_example_groups_for('main', *ancestors[0..-1])
    end

shared_examples(*args, &block) click to toggle source

@overload shared_examples(name, &block) @overload shared_examples(name, tags, &block)

Wraps the `block` in a module which can then be included in example groups using `include_examples`, `include_context`, or `it_behaves_like`.

@param [String] name to match when looking up this shared group @param block to be eval'd in a nested example group generated by `it_behaves_like`

@example

    shared_examples "auditable" do
      it "stores an audit record on save!" do
        lambda { auditable.save! }.should change(Audit, :count).by(1)
      end
    end

    class Account do
      it_behaves_like "auditable" do
        def auditable; Account.new; end
      end
    end

@see ExampleGroup.it_behaves_like @see ExampleGroup.include_examples @see ExampleGroup.include_context

    # File lib/rspec/core/shared_example_group.rb, line 31
    def shared_examples(*args, &block)
      SharedExampleGroup.registry.add_group(self, *args, &block)
    end

Also aliased as: shared_context, share_examples_for, shared_examples_for
shared_examples_for(*args, &block) click to toggle source
Alias for: shared_examples

[Validate]

Generated with the Darkfish Rdoc Generator 2.