Class: Transpec::AST::ScopeStack

Inherits:
Array
  • Object
show all
Defined in:
lib/transpec/ast/scope_stack.rb

Constant Summary collapse

EXAMPLE_GROUP_METHOD_NAMES =
[
  :describe, :context,
  :shared_examples, :shared_context, :share_examples_for, :shared_examples_for
].freeze

Instance Method Summary collapse

Instance Method Details

#in_example_group_context?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/transpec/ast/scope_stack.rb', line 21

def in_example_group_context?
  if include?(:example_group)
    scopes_in_example_group = inner_scopes_in_scope(:example_group)
    return false if include_class_scope?(scopes_in_example_group)
    include_method_or_block_scope?(scopes_in_example_group)
  elsif include?(:rspec_configure)
    scopes_in_rspec_configure = inner_scopes_in_scope(:rspec_configure)
    return false if include_class_scope?(scopes_in_rspec_configure)
    include_method_or_block_scope?(scopes_in_rspec_configure)
  elsif first == :def
    scopes_in_method = self[1..-1]
    !include_class_scope?(scopes_in_method)
  elsif include?(:module)
    scopes_in_module = inner_scopes_in_scope(:module)
    return false if include_class_scope?(scopes_in_module)
    scopes_in_module.include?(:def)
  else
    false
  end
end

#pop_scopeObject



17
18
19
# File 'lib/transpec/ast/scope_stack.rb', line 17

def pop_scope
  pop
end

#push_scope(node) ⇒ Object



13
14
15
# File 'lib/transpec/ast/scope_stack.rb', line 13

def push_scope(node)
  push(scope_type(node))
end