Sha256: 2a6b2b9e172a1cd5e37dda9c29291ba59cb48d08e5c2d1a1e2e14f90b82268bf

Contents?: true

Size: 1.37 KB

Versions: 22

Compression:

Stored size: 1.37 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', ''], ['', '4']]
      end

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

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
davidtrogers-cucumber-0.6.2 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.6.2 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.6.1 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.6.0 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.5.3 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.5.2 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.5.1 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.5.0 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.5.rc2 spec/cucumber/parser/table_parser_spec.rb
kbaum-cucumber-0.4.5.pre spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.5.rc1 spec/cucumber/parser/table_parser_spec.rb
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/parser/table_parser_spec.rb
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/parser/table_parser_spec.rb
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/parser/table_parser_spec.rb
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/parser/table_parser_spec.rb
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.4 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.3 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.2 spec/cucumber/parser/table_parser_spec.rb
cucumber-0.4.1 spec/cucumber/parser/table_parser_spec.rb