Sha256: af64355ccd8ffb3b0f93891cded54f6500dd6179c4ba9dfb73f11cbdb82457cf

Contents?: true

Size: 1.26 KB

Versions: 102

Compression:

Stored size: 1.26 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'treetop'
require 'cucumber/parser'

module Cucumber
  module Parser
    describe 'Tables' do
      before do
        @parser = FeatureParser.new
      end
      
      def parse(text)
        @parser.__send__(:prepare_to_parse, text)
        @parser.root = :table
        table = @parser._nt_table
        table.raw
      end

      it "should parse a 1x2 table with newline" do
        parse(" | 1 | 2 | \n").should == [%w{1 2}]
      end

      it "should parse a 1x2 table without newline" do
        parse("| 1 | 2 |").should == [%w{1 2}]
      end

      it "should parse a 1x2 table without spaces" do
        parse("|1|2|").should == [%w{1 2}]
      end

      it "should parse a 2x2 table" do
        parse("| 1 | 2 |\n| 3 | 4 |\n").should == [%w{1 2}, %w{3 4}]
      end

      it "should parse a 2x2 table with several newlines" do
        parse("| 1 | 2 |\n| 3 | 4 |\n\n\n").should == [%w{1 2}, %w{3 4}]
      end

      it "should parse a 2x2 table with empty cells" do
        parse("| 1 |  |\n|| 4 |\n").should == [['1', nil], [nil, '4']]
      end

      it "should not parse a 2x2 table that isn't closed" do
        parse("| 1 |  |\n|| 4 ").should_not == [['1', nil], [nil, '4']]
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 6 rubygems

Version Path
aslakhellesoy-cucumber-0.1.100.1 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.100.2 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.100.3 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.100.4 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.100.5 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.16.5 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.1 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.10 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.11 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.12 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.13 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.14 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.15 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.17 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.18 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.19 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.2 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.20 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.21 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.1.99.22 spec/cucumber/parser/table_parser_spec.rb