Module: RSpec::Core::SharedContext

Includes:
Hooks, Let::ExampleGroupMethods
Defined in:
lib/rspec/core/shared_context.rb

Overview

Exposes [ExampleGroup](ExampleGroup)-level methods to a module, so you can include that module in an [ExampleGroup](ExampleGroup).

Examples:


module LoggedInAsAdmin
  extend RSpec::Core::SharedContext
  before(:each) do
     :admin
  end
end

describe "admin section" do
  include LoggedInAsAdmin
  # ...
end

Instance Method Summary collapse

Methods included from Let::ExampleGroupMethods

#let, #let!

Methods included from Hooks

#after, #around, #before, #find_hook, #hooks, #run_hook, #run_hook!, #run_hook_filtered

Methods included from MetadataHashBuilder::Common

#build_metadata_hash_from

Instance Method Details

#describe(name, *args, &block) ⇒ Object Also known as: context



34
35
36
# File 'lib/rspec/core/shared_context.rb', line 34

def describe(name, *args, &block)
  _nested_group_declarations << [name, block, *args]
end

#included(group) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/rspec/core/shared_context.rb', line 23

def included(group)
  [:before, :after].each do |type|
    [:all, :each].each do |scope|
      group.hooks[type][scope].concat hooks[type][scope]
    end
  end
  _nested_group_declarations.each do |name, block, *args|
    group.describe name, *args, &block
  end
end