Class: Test::Unit::TestCase

Inherits:
Object show all
Defined in:
lib/spec/test_to_spec/test_case_ext.rb

Class Method Summary collapse

Class Method Details

.to_rspecObject

Returns a String representing the RSpec translation of this class



10
11
12
13
14
15
16
17
18
19
# File 'lib/spec/test_to_spec/test_case_ext.rb', line 10

def self.to_rspec
  tree = ParseTree.new.parse_tree(self).first
  rspec_tree = Spec::TestToSpec::SexpTransformer.new.process(tree)
  modules = self.name.split("::")[0..-2]
  result = ""
  result += modules.collect{|m| "module #{m}\n"}.join("")
  result += RubyToRuby.new.process(rspec_tree[0])
  result += modules.collect{|m| "\nend"}.join("")
  result
end