Module: RSpec::SleepingKingStudios::Deferred::Examples::ClassMethods

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

Overview

Class methods for deferred examples.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parent_groupRSpec::SleepingKingStudios::Deferred::Examples

Returns the deferred example group where this example group was included, if any.

Returns:



14
15
16
# File 'lib/rspec/sleeping_king_studios/deferred/examples.rb', line 14

def parent_group
  @parent_group
end

#source_locationArray<String, Integer>

Returns the Ruby source filename and line number where the deferred example group was defined.

Returns:

  • (Array<String, Integer>)

    the Ruby source filename and line number where the deferred example group was defined.



18
19
20
# File 'lib/rspec/sleeping_king_studios/deferred/examples.rb', line 18

def source_location
  @source_location
end

Instance Method Details

#deferred_examples?Boolean

Returns flag indicating that the included module has deferred examples, rather than including another deferred examples module.

Returns:

  • (Boolean)

    flag indicating that the included module has deferred examples, rather than including another deferred examples module.



40
41
42
# File 'lib/rspec/sleeping_king_studios/deferred/examples.rb', line 40

def deferred_examples?
  true
end

#descriptionString

Returns the description for the deferred examples. By default, formats the last segment of the module name in lowercase words, excepting any trailing “Context” or “Examples”.

Returns:

  • (String)

    the description for the deferred examples. By default, formats the last segment of the module name in lowercase words, excepting any trailing “Context” or “Examples”.



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

def description
  return @description if @description

  return @description = '(anonymous examples)' if name.nil?

  @description = format_description
end

#description=(value) ⇒ Object

Parameters:

  • value (String)

    the description for the deferred examples.



32
33
34
35
36
# File 'lib/rspec/sleeping_king_studios/deferred/examples.rb', line 32

def description=(value)
  tools.assertions.validate_name(value, as: 'description')

  @description = value.to_s.tr('_', ' ')
end