module RSpec::SleepingKingStudios::Concerns::WrapExamples

Methods for encapsulating shared example groups to include contexts or examples without affecting the surrounding context.

Public Instance Methods

fwrap_context(name, *args, **kwargs, &block)
Alias for: fwrap_examples
fwrap_examples(name, *args, **kwargs, &block) click to toggle source

Includes the specified shared example group and wraps it inside a focused ‘fdescribe` block. If a block is provided, it is evaluated in the context of the fdescribe block after the example group has been included.

@param [String] name The name of the shared example group to be wrapped. @param [Array] args Optional array of arguments that are passed on to

the shared example group.

@param [Hash] kwargs Optional hash of keyword arguments that are passed

on to the shared example group.

@yield Additional code to run in the context of the wrapping ‘fdescribe`

block, such as additional examples or memoized values.
# File lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb, line 46
def fwrap_examples name, *args, **kwargs, &block
  fdescribe name do
    if kwargs.empty?
      include_examples name, *args
    else
      include_examples name, *args, **kwargs
    end # if-else

    instance_eval(&block) if block_given?
  end # describe
end
Also aliased as: fwrap_context
wrap_context(name, *args, **kwargs, &block)
Alias for: wrap_examples
wrap_examples(name, *args, **kwargs, &block) click to toggle source

Includes the specified shared example group and wraps it inside a ‘describe` block. If a block is provided, it is evaluated in the context of the describe block after the example group has been included.

@param [String] name The name of the shared example group to be wrapped. @param [Array] args Optional array of arguments that are passed on to

the shared example group.

@param [Hash] kwargs Optional hash of keyword arguments that are passed

on to the shared example group.

@yield Additional code to run in the context of the wrapping ‘describe`

block, such as additional examples or memoized values.
# File lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb, line 21
def wrap_examples name, *args, **kwargs, &block
  describe name do
    if kwargs.empty?
      include_examples name, *args
    else
      include_examples name, *args, **kwargs
    end # if-else

    instance_eval(&block) if block_given?
  end # describe
end
Also aliased as: wrap_context
xwrap_context(name, *args, **kwargs, &block)
Alias for: xwrap_examples
xwrap_examples(name, *args, **kwargs, &block) click to toggle source

Includes the specified shared example group and wraps it inside a skipped ‘xdescribe` block. If a block is provided, it is evaluated in the context of the xdescribe block after the example group has been included. Mostly used to temporarily disable a wrapped example group while updating or debugging a spec.

@param [String] name The name of the shared example group to be wrapped. @param [Array] args Optional array of arguments that are passed on to

the shared example group.

@param [Hash] kwargs Optional hash of keyword arguments that are passed

on to the shared example group.

@yield Additional code to run in the context of the wrapping ‘fdescribe`

block, such as additional examples or memoized values.
# File lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb, line 73
def xwrap_examples name, *args, **kwargs, &block
  xdescribe name do
    if kwargs.empty?
      include_examples name, *args
    else
      include_examples name, *args, **kwargs
    end # if-else

    instance_eval(&block) if block_given?
  end # describe
end
Also aliased as: xwrap_context