Class: RSpec::SleepingKingStudios::Deferred::Calls::Example

Inherits:
RSpec::SleepingKingStudios::Deferred::Call show all
Defined in:
lib/rspec/sleeping_king_studios/deferred/calls/example.rb

Overview

Value object representing a deferred RSpec example.

Instance Attribute Summary collapse

Attributes inherited from RSpec::SleepingKingStudios::Deferred::Call

#arguments, #block, #keywords, #method_name

Instance Method Summary collapse

Methods inherited from RSpec::SleepingKingStudios::Deferred::Call

#==

Constructor Details

#initialize(method_name, *arguments, deferred_example_group: nil, **keywords, &block) ⇒ Example

Returns a new instance of Example.

Parameters:

  • method_name (String, Symbol)

    the name of the method to call.

  • arguments (Array)

    the arguments to pass to the method.

  • keywords (Hash)

    the keywords to pass to the method.

  • deferred_example_group (Deferred::Examples) (defaults to: nil)

    the deferred example group defining the deferred call.

  • block (Proc)

    the block to pass to the method.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rspec/sleeping_king_studios/deferred/calls/example.rb', line 15

def initialize(
  method_name,
  *arguments,
  deferred_example_group: nil,
  **keywords,
  &block
)
  super(method_name, *arguments, **keywords, &block)

  @deferred_example_group = deferred_example_group
end

Instance Attribute Details

#deferred_example_groupDeferred::Examples (readonly)

Returns the deferred example group defining the deferred call.

Returns:



29
30
31
# File 'lib/rspec/sleeping_king_studios/deferred/calls/example.rb', line 29

def deferred_example_group
  @deferred_example_group
end

Instance Method Details

#call(receiver) ⇒ Object

Invokes the deferred method call on the receiver.

Parameters:

  • receiver (Object)

    the receiver for the method call.

Returns:

  • (Object)

    the returned value of the method call.



32
33
34
35
36
37
38
39
40
# File 'lib/rspec/sleeping_king_studios/deferred/calls/example.rb', line 32

def call(receiver)
  example = super

  # Store a reference to the deferred group when adding to an actual example
  # group.
  example.[:deferred_example_group] = @deferred_example_group

  example
end