class Transpec::SpecSuite

Attributes

project[R]
runtime_data[R]
target_paths[R]

Public Class Methods

new(project = Project.new, target_paths = [], runtime_data = nil) click to toggle source
# 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

Public Instance Methods

analyze() click to toggle source
# 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) click to toggle source
# 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?() click to toggle source
# 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
specs() click to toggle source
# 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

Private Instance Methods

process_any_instance_block(syntax) click to toggle source
# File lib/transpec/spec_suite.rb, line 60
def process_any_instance_block(syntax)
  @need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config ||=
    syntax.need_to_add_receiver_arg_to_any_instance_implementation_block?
end
process_rspec_configure(rspec_configure) click to toggle source
# File lib/transpec/spec_suite.rb, line 65
def process_rspec_configure(rspec_configure)
  return unless runtime_data
  run_order = runtime_data[rspec_configure.node, :run_order]
  return unless run_order

  unless @main_rspec_configure
    @main_rspec_configure = rspec_configure
    return
  end

  if run_order < runtime_data[@main_rspec_configure.node, :run_order]
    @main_rspec_configure = rspec_configure
  end
end