josephwilk (owner)

Fork Of

Revisions

gist: 35463 Download_button fork
public
Public Clone URL: git://gist.github.com/35463.git
Embed All Files: show embed
cucumber/parser/table.tt #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Cucumber
  module Parser
    grammar Table
      rule record
        (cell_value separator record) / cell_value
      end
      
      rule separator
        '|'
      end
      
      rule cell_value
        (!separator .)+
      end
    end
  end
end
 
cucumber/parser/table_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require File.dirname(__FILE__) + '/../../spec_helper'
require 'treetop'
require 'cucumber/parser/table'
 
module Cucumber
  module Parser
    describe Table do
      before do
        @parser = TableParser.new
      end
      
      def parse(text)
        @parser.parse(text) || raise(@parser.failure_reason)
      end
 
      it "should parse a row with one cell" do
        parse("hi")
      end
 
      it "should parse a row with two cells" do
        parse("hello|there")
      end
    end
  end
end