Module: RSpec::SleepingKingStudios::Deferred::Dsl::Hooks

Included in:
RSpec::SleepingKingStudios::Deferred::Dsl
Defined in:
lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb

Overview

Domain-specific language for defining deferred hooks.

Instance Method Summary collapse

Instance Method Details

#after(scope, *flags, **conditions, &block) ⇒ void

This method returns an undefined value.

Defines a deferred hook using the #after method.

Parameters:

  • scope (Symbol)

    the scope for the hook. Must be one of :context, :each, or :example.

  • flags (Array<Symbol>)

    condition flags for the hook. Will be transformed into conditions entries with true values.

  • block (Proc)

    the implementation of the hook.



19
20
21
22
23
24
25
26
27
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 19

def after(scope, *flags, **conditions, &)
  deferred_hooks << RSpec::SleepingKingStudios::Deferred::Calls::Hook.new(
    :after,
    scope,
    *flags,
    **conditions,
    &
  )
end

#append_after(scope, *flags, **conditions, &block) ⇒ void

This method returns an undefined value.

Defines a deferred hook using the #append_after method.

Parameters:

  • scope (Symbol)

    the scope for the hook. Must be one of :context, :each, or :example.

  • flags (Array<Symbol>)

    condition flags for the hook. Will be transformed into conditions entries with true values.

  • block (Proc)

    the implementation of the hook.



39
40
41
42
43
44
45
46
47
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 39

def append_after(scope, *flags, **conditions, &)
  deferred_hooks << RSpec::SleepingKingStudios::Deferred::Calls::Hook.new(
    :append_after,
    scope,
    *flags,
    **conditions,
    &
  )
end

#around(scope, *flags, **conditions, &block) ⇒ void

This method returns an undefined value.

Defines a deferred hook using the #around method.

Parameters:

  • scope (Symbol)

    the scope for the hook. Must be one of :context, :each, or :example.

  • flags (Array<Symbol>)

    condition flags for the hook. Will be transformed into conditions entries with true values.

  • block (Proc)

    the implementation of the hook.



59
60
61
62
63
64
65
66
67
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 59

def around(scope, *flags, **conditions, &)
  deferred_hooks << RSpec::SleepingKingStudios::Deferred::Calls::Hook.new(
    :around,
    scope,
    *flags,
    **conditions,
    &
  )
end

#before(scope, *flags, **conditions, &block) ⇒ void

This method returns an undefined value.

Defines a deferred hook using the #before method.

Parameters:

  • scope (Symbol)

    the scope for the hook. Must be one of :context, :each, or :example.

  • flags (Array<Symbol>)

    condition flags for the hook. Will be transformed into conditions entries with true values.

  • block (Proc)

    the implementation of the hook.



79
80
81
82
83
84
85
86
87
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 79

def before(scope, *flags, **conditions, &)
  deferred_hooks << RSpec::SleepingKingStudios::Deferred::Calls::Hook.new(
    :before,
    scope,
    *flags,
    **conditions,
    &
  )
end

#call(example_group) ⇒ void

This method returns an undefined value.

Invokes the deferred examples on the given example group.

Parameters:

  • example_group (RSpec::Core::ExampleGroup)

    the example group.



90
91
92
93
94
95
96
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 90

def call(example_group)
  super

  deferred_hooks.reverse_each do |deferred_hook|
    deferred_hook.call(example_group)
  end
end

#deferred_hooksObject



99
100
101
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 99

def deferred_hooks
  @deferred_hooks ||= []
end

#prepend_before(scope, *flags, **conditions, &block) ⇒ void

This method returns an undefined value.

Defines a deferred hook using the #prepend_before method.

Parameters:

  • scope (Symbol)

    the scope for the hook. Must be one of :context, :each, or :example.

  • flags (Array<Symbol>)

    condition flags for the hook. Will be transformed into conditions entries with true values.

  • block (Proc)

    the implementation of the hook.



113
114
115
116
117
118
119
120
121
# File 'lib/rspec/sleeping_king_studios/deferred/dsl/hooks.rb', line 113

def prepend_before(scope, *flags, **conditions, &)
  deferred_hooks << RSpec::SleepingKingStudios::Deferred::Calls::Hook.new(
    :prepend_before,
    scope,
    *flags,
    **conditions,
    &
  )
end