Class: TodoNext::Tree::Visitor::RspecGenerator
- Inherits:
-
Base
- Object
- Base
- TodoNext::Tree::Visitor::RspecGenerator
show all
- Defined in:
- lib/todo_next/tree/visitor/rspec_generator.rb
Instance Method Summary
collapse
Methods inherited from Base
#visit, #visit_children_of
Instance Method Details
#label(node) ⇒ Object
20
21
22
23
24
|
# File 'lib/todo_next/tree/visitor/rspec_generator.rb', line 20
def label(node)
text = node.text
text.gsub! /^[-\+]\s*/,''
text
end
|
#process_non_terminal_node(curr_node, level, parent) ⇒ Object
14
15
16
17
18
|
# File 'lib/todo_next/tree/visitor/rspec_generator.rb', line 14
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
|
#process_terminal_node(curr_node, level, parent) ⇒ Object
8
9
10
11
12
|
# File 'lib/todo_next/tree/visitor/rspec_generator.rb', line 8
def process_terminal_node(curr_node, level, parent)
tabs = ' '*(level-1)
label = label(curr_node)
code = %Q|#{tabs}it("#{label}", :pending => "#{label}"){}|
end
|