Sha256: 625e29fcb2af08ae7d56ff81cae3cc14c724c1f3813cc3b4bf92c92bd807e85c

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require File.dirname(__FILE__) + '/base'

module TodoNext
  class Tree
    module Visitor
      class RspecGenerator < Base

        def process_terminal_node(curr_node, level, parent)
          tabs  = '  '*(level-1)
          label = label(curr_node)
          code = %Q|#{tabs}it("#{label}", :pending => "#{label}"){}|
        end

        def process_non_terminal_node(curr_node, level, parent)
          tabs = '  '*(level-1)
          codes = curr_node.children.collect { |node| visit(node, 1+level, parent=self) }
          [%Q|#{tabs}describe "#{label(curr_node)}" do|] + codes + ["#{tabs}end"]
        end

        def label(node)
          text = node.text
          text.gsub! /^[-\+]\s*/,''
          text
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
todo_next-0.0.2 lib/todo_next/tree/visitor/rspec_generator.rb