Class: AppMap::RSpec::ScopeExampleGroup

Inherits:
Struct
  • Object
show all
Defined in:
lib/appmap/rspec.rb

Overview

As you can see here, the way that RSpec stores the example description and represents the example group hierarchy is pretty weird.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#example_groupObject Also known as: example_obj

Returns the value of attribute example_group

Returns:

  • (Object)

    the current value of example_group



37
38
39
# File 'lib/appmap/rspec.rb', line 37

def example_group
  @example_group
end

Instance Method Details

#descriptionObject



53
54
55
# File 'lib/appmap/rspec.rb', line 53

def description
  description? ? description_args.join(' ') : nil
end

#description?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/appmap/rspec.rb', line 45

def description?
  return true if example_group.respond_to?(:described_class) && example_group.described_class

  return true if example_group.respond_to?(:description) && !description_args.empty?

  false
end

#description_argsObject



40
41
42
43
# File 'lib/appmap/rspec.rb', line 40

def description_args
  # Don't stringify any hashes that RSpec considers part of the example group description.
  example_group.[:description_args].reject { |arg| arg.is_a?(Hash) }
end

#parentObject



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

def parent
  # An example group always has a parent; but it might be 'self'...

  # DEPRECATION WARNING: `Module#parent` has been renamed to `module_parent`. `parent` is deprecated and will be
  # removed in Rails 6.1. (called from parent at /Users/kgilpin/source/appland/appmap-ruby/lib/appmap/rspec.rb:110)
  example_group_parent = \
    if example_group.respond_to?(:module_parent)
      example_group.module_parent
    elsif example_group.respond_to?(:parent)
      example_group.parent
    elsif example_group.respond_to?(:parent_groups)
      example_group.parent_groups.first
    end

  example_group_parent != example_group ? ScopeExampleGroup.new(example_group_parent) : nil
end