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(project = Project.new, target_paths = [], runtime_data = nil) ⇒ SpecSuite

Returns a new instance of SpecSuite.



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

def initialize(project = Project.new, target_paths = [], runtime_data = nil)
  @project = project
  @target_paths = target_paths
  @runtime_data = runtime_data
  @analyzed = false
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

#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

#target_pathsObject (readonly)

Returns the value of attribute target_paths.



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

def target_paths
  @target_paths
end

Instance Method Details

#analyzeObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/transpec/spec_suite.rb', line 30

def analyze
  return if @analyzed

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

  @analyzed = true
end

#main_rspec_configure_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
# File 'lib/transpec/spec_suite.rb', line 48

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)


43
44
45
46
# File 'lib/transpec/spec_suite.rb', line 43

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



22
23
24
25
26
27
28
# File 'lib/transpec/spec_suite.rb', line 22

def specs
  @specs ||= Dir.chdir(project.path) do
    SpecFileFinder.find(target_paths).map do |path|
      ProcessedSource.from_file(path)
    end
  end
end