require 'test_helper' module LucidTDL describe 'Full Test Specification Parsing' do before do @scenario = """Feature: Ability to use Lucid TDL As a test specification writer I need a test description language so that I can structure tests Background: Given a generic context And one that happens for all scenarios Scenario: A basic test When an action takes place Then an observable occurs @selenium @wip Scenario: Another basic test When another action takes place Then another observable occurs """ parser = LucidTDL::Parser.new @result = parser.parse(@scenario) end it "generates a tree hierarchy" do @result.must_be_kind_of AST::Feature @result.line.must_equal 1 @result.description.must_equal [ "As a test specification writer", "I need a test description language", "so that I can structure tests"] background = @result.background background.must_be_kind_of AST::Background background.line.must_equal 6 background.steps.first.keyword.must_equal 'Given' background.steps.first.name.must_equal 'a generic context' background.steps.first.line.must_equal 7 background.steps.last.keyword.must_equal 'And' background.steps.last.name.must_equal 'one that happens for all scenarios' background.steps.last.line.must_equal 8 first_scenario = @result.scenarios.first first_scenario.must_be_kind_of AST::Scenario first_scenario.line.must_equal 10 first_scenario.name.must_equal 'A basic test' first_scenario.steps.first.keyword.must_equal 'When' first_scenario.steps.first.name.must_equal 'an action takes place' first_scenario.steps.first.line.must_equal 11 first_scenario.steps.last.keyword.must_equal 'Then' first_scenario.steps.last.name.must_equal 'an observable occurs' first_scenario.steps.last.line.must_equal 12 last_scenario = @result.scenarios.last last_scenario.must_be_kind_of AST::Scenario last_scenario.line.must_equal 15 last_scenario.name.must_equal 'Another basic test' last_scenario.tags.first.name.must_equal 'selenium' last_scenario.tags.last.name.must_equal 'wip' last_scenario.steps.first.keyword.must_equal 'When' last_scenario.steps.first.name.must_equal 'another action takes place' last_scenario.steps.first.line.must_equal 16 last_scenario.steps.last.keyword.must_equal 'Then' last_scenario.steps.last.name.must_equal 'another observable occurs' last_scenario.steps.last.line.must_equal 17 end end end