Module: RSpec::SleepingKingStudios::Deferred::Consumer::ClassMethods

Defined in:
lib/rspec/sleeping_king_studios/deferred/consumer.rb

Overview

Class methods for registering deferred examples.

Instance Method Summary collapse

Instance Method Details

#finclude_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples inside a focused example group.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    a block passed to the deferred examples.



24
25
26
27
28
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 24

def finclude_deferred(description, ...)
  fdescribe '(focused)' do
    include_deferred(description, ...)
  end
end

#fwrap_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples inside a focused example group.

Unlike #include_deferred, a block parameter will be included in the created example group, not passed to the deferred examples. To wrap deferred examples that require a block, create the example group separately and call #include_deferred.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    additional examples to be evaluated inside the example group.



43
44
45
46
47
48
49
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 43

def fwrap_deferred(description, *args, **kwargs, &block)
  fdescribe "(focused) #{description}" do
    include_deferred(description, *args, **kwargs)

    instance_exec(&block) if block_given?
  end
end

#include_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples with the given definition.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    a block passed to the deferred examples.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 58

def include_deferred(description, ...)
  deferred = find_deferred_examples(description)

  deferred =
    if deferred.is_a?(Proc)
      define_deferred_module(deferred, description, ...)
    else
      wrap_deferred_module(deferred)
    end

  deferred.parent_group = self

  include deferred
end

#wrap_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples inside an example group.

Unlike #include_deferred, a block parameter will be included in the created example group, not passed to the deferred examples. To wrap deferred examples that require a block, create the example group separately and call #include_deferred.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    additional examples to be evaluated inside the example group.



86
87
88
89
90
91
92
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 86

def wrap_deferred(description, *args, **kwargs, &block)
  describe description do
    include_deferred(description, *args, **kwargs)

    instance_exec(&block) if block_given?
  end
end

#xinclude_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples inside a skipped example group.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    a block passed to the deferred examples.



101
102
103
104
105
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 101

def xinclude_deferred(description, ...)
  xdescribe '(skipped)' do
    include_deferred(description, ...)
  end
end

#xwrap_deferred(description, *arguments, **keywords, &block) ⇒ Object

Includes the deferred examples inside a skipped example group.

Unlike #include_deferred, a block parameter will be included in the created example group, not passed to the deferred examples. To wrap deferred examples that require a block, create the example group separately and call #include_deferred.

Parameters:

  • description (String)

    the name of the deferred examples.

  • arguments (Array)

    arguments passed to the deferred examples.

  • keywords (Hash)

    keywords passed to the deferred examples.

  • block (Block)

    additional examples to be evaluated inside the example group.



120
121
122
123
124
125
126
# File 'lib/rspec/sleeping_king_studios/deferred/consumer.rb', line 120

def xwrap_deferred(description, *args, **kwargs, &block)
  xdescribe "(skipped) #{description}" do
    include_deferred(description, *args, **kwargs)

    instance_exec(&block) if block_given?
  end
end