class MinitestToRspec::Converter

Converts strings of minitest code. Does not read or write files.

Public Class Methods

new(rails: false, mocha: false) click to toggle source
# File lib/minitest_to_rspec/converter.rb, line 11
def initialize(rails: false, mocha: false)
  @processor = Input::Processor.new(rails, mocha)
end

Public Instance Methods

convert(input, file_path = nil) click to toggle source
  • `input` - Contents of a ruby file.

  • `file_path` - Optional. Value will replace any `__FILE__` keywords in the input.

# File lib/minitest_to_rspec/converter.rb, line 18
def convert(input, file_path = nil)
  render process parse(input, file_path)
end

Private Instance Methods

parse(input, file_path) click to toggle source

Parses input string and returns Abstract Syntax Tree (AST) as an S-expression.

# File lib/minitest_to_rspec/converter.rb, line 26
def parse(input, file_path)
  file_path ||= "No file path provided to #{self.class}#convert"
  RubyParser.new.parse(input, file_path)
end
process(exp) click to toggle source

Processes an AST (S-expressions) representing a minitest file, and returns an AST (still S-expressions) representing an rspec file.

# File lib/minitest_to_rspec/converter.rb, line 34
def process(exp)
  @processor.process(exp)
end
render(exp) click to toggle source

Given an AST representing an rspec file, returns a string of ruby code.

# File lib/minitest_to_rspec/converter.rb, line 40
def render(exp)
  renderer.process(exp)
end
renderer() click to toggle source
# File lib/minitest_to_rspec/converter.rb, line 44
def renderer
  Ruby2Ruby.new
end