require 'test_helper' module LucidTDL describe Parser do before do @lexer = Parser.new end it "will ignore commented lines" do @lexer.tokenize("# Commented line").must_equal [] end it "can parse a single newline character" do @lexer.tokenize("\n").must_equal [[:NEWLINE, "\n"]] end it "can parse multiple newline characters" do @lexer.tokenize("\n\n").must_equal [[:NEWLINE, "\n"], [:NEWLINE, "\n"]] end it "can parse text strings" do @lexer.tokenize("simple text").must_equal [[:TEXT, "simple text"]] end it "strip parsed text strings" do @lexer.tokenize(" simple text ").must_equal [[:TEXT, "simple text"]] end it "parses a single tag" do @lexer.tokenize("@selenium @headless").must_equal [ [:TAG, "selenium"], [:TAG, "headless"], ] end it "parses multiple tags" do end describe "high-level structural keywords" do %w(Feature: Ability: Responsibility:).each do |keyword| it "parses #{keyword}:" do name = keyword[0..-2] @lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]] end end end describe "operational structural keywords" do %w(Background: Scenario: Test:).each do |keyword| it "parses #{keyword}:" do name = keyword[0..-2] @lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]] end end end describe "specific step keywords" do %w(Given When Then And But).each do |keyword| it "parses #{keyword}" do @lexer.tokenize(keyword).must_equal [[keyword.upcase.to_sym, keyword]] end end end describe "generic step keywords" do %w(*).each do |keyword| it "parses #{keyword}" do @lexer.tokenize(keyword).must_equal [[:GENERIC, "*"]] end end end end end