Class: Transpec::Context
- Inherits:
-
Object
- Object
- Transpec::Context
- Includes:
- Util
- Defined in:
- lib/transpec/context.rb
Constant Summary collapse
- SCOPE_TYPES =
[:module, :class, :sclass, :def, :defs, :block].freeze
- EXAMPLE_GROUP_METHOD_NAMES =
[ :describe, :context, :shared_examples, :shared_context, :share_examples_for, :shared_examples_for ].freeze
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #in_example_group? ⇒ Boolean
-
#initialize(nodes) ⇒ Context
constructor
A new instance of Context.
- #scopes ⇒ Object
Methods included from Util
const_name, here_document?, in_parentheses?, indentation_of_line, proc_literal?
Constructor Details
#initialize(nodes) ⇒ Context
Returns a new instance of Context.
19 20 21 |
# File 'lib/transpec/context.rb', line 19 def initialize(nodes) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
16 17 18 |
# File 'lib/transpec/context.rb', line 16 def nodes @nodes end |
Instance Method Details
#in_example_group? ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/transpec/context.rb', line 30 def in_example_group? return @in_example_group if instance_variable_defined?(:@in_example_group) @in_example_group = in_method_or_block_in_example_group? || in_method_or_block_in_rspec_configure? || in_method_in_module? || in_method_in_top_level? end |
#scopes ⇒ Object
23 24 25 26 27 28 |
# File 'lib/transpec/context.rb', line 23 def scopes @scopes ||= begin scopes = @nodes.map { |node| scope_type(node) } scopes.compact end end |