Class: Transpec::SpecSuite

Inherits:
Object
  • Object
show all
Includes:
Transpec::Syntax::Dispatcher
Defined in:
lib/transpec/spec_suite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Transpec::Syntax::Dispatcher

#dispatch_node, #dispatch_syntax, #handler_names, #invoke_handler

Constructor Details

#initialize(base_paths = [], runtime_data = nil) ⇒ SpecSuite

Returns a new instance of SpecSuite.



15
16
17
18
19
# File 'lib/transpec/spec_suite.rb', line 15

def initialize(base_paths = [], runtime_data = nil)
  @base_paths = base_paths
  @runtime_data = runtime_data
  @analyzed = false
end

Instance Attribute Details

#runtime_dataObject (readonly)

Returns the value of attribute runtime_data.



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

def runtime_data
  @runtime_data
end

Instance Method Details

#analyzeObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/transpec/spec_suite.rb', line 27

def analyze
  return if @analyzed

  specs.each do |spec|
    next unless spec.ast
    spec.ast.each_node do |node|
      dispatch_node(node, nil, runtime_data)
    end
  end

  @analyzed = true
end

#main_rspec_configure_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
# File 'lib/transpec/spec_suite.rb', line 45

def main_rspec_configure_node?(node)
  analyze

  if @main_rspec_configure
    @main_rspec_configure.node.equal?(node)
  else
    true
  end
end

#need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/transpec/spec_suite.rb', line 40

def need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?
  analyze
  @need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config
end

#specsObject



21
22
23
24
25
# File 'lib/transpec/spec_suite.rb', line 21

def specs
  @specs ||= FileFinder.find(@base_paths).map do |path|
    ProcessedSource.parse_file(path)
  end
end