Sha256: 0500b586b2e4e4ad116b21d04d12a309803590ce198f2cf2087362a0b127a058

Contents?: true

Size: 1.38 KB

Versions: 24

Compression:

Stored size: 1.38 KB

Contents

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

module Cucumber
  module Parser
    describe 'Tables' do
      before do
        @parser = NaturalLanguage.get(StepMother.new, 'en').parser
      end
      
      after do
        NaturalLanguage.instance_variable_set(:@languages, nil)
      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

24 entries across 24 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.3.100 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.101.2 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.101 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.102.1 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.102.2 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.102 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.103 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.104 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.98 spec/cucumber/parser/table_parser_spec.rb
aslakhellesoy-cucumber-0.3.99 spec/cucumber/parser/table_parser_spec.rb
dwaite-cucumber-0.3.101 spec/cucumber/parser/table_parser_spec.rb
engineyard-cucumber-0.3.101 spec/cucumber/parser/table_parser_spec.rb
kosmas58-cucumber-0.3.100 spec/cucumber/parser/table_parser_spec.rb
kosmas58-cucumber-0.3.102 spec/cucumber/parser/table_parser_spec.rb
kosmas58-cucumber-0.3.103 spec/cucumber/parser/table_parser_spec.rb
kosmas58-cucumber-0.3.98 spec/cucumber/parser/table_parser_spec.rb
kosmas58-cucumber-0.3.99 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.3.104 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.3.103 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.3.102 spec/cucumber/parser/table_parser_spec.rb