Module: RSpec::Core::SharedContext

Includes:
Hooks, MemoizedHelpers::ClassMethods
Defined in:
lib/rspec/core/shared_context.rb

Overview

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

Examples:


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

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

Constant Summary

Instance Method Summary (collapse)

Methods included from MemoizedHelpers::ClassMethods

#its, #let, #let!, #subject, #subject!

Methods included from Hooks

#after, #append_after, #around, #before, #prepend_before

Instance Method Details

- (Object) describe(name, *args, &block) 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

- (Object) included(group)



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