Sha256: d973ea3d0ae03c9911423f1936da0aabfe8410b5dc945325fd0151fa6e19445f

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'gherkin/parser/parser'

module Gherkin
  module Parser
    describe Parser do
      before do
        @listener = mock('listener')
        @parser = Parser.new(@listener, true)
      end

      it "should delegate events to the listener" do
        @listener.should_receive(:comment).with("# Content", 1)
        @parser.comment("# Content", 1)
      end

      it "should raise helpful error messages by default" do
        lambda { 
          @parser.scenario("Scenario", "My pet scenario", 12) 
        }.should raise_error(/Parse error on line 12\. Found scenario when expecting one of: comment, feature, tag\. \(Current state: root\)\.$/)
      end

      it "should allow empty files" do
        @listener.should_receive(:eof)
        @parser.eof
      end

      it "should delegate an error message when raise on error is false" do
        @listener.should_receive(:syntax_error).with(sym(:root), sym(:background), a([:comment, :feature, :tag]), 1)
        @parser = Parser.new(@listener, false)
        @parser.background("Background", "Content", 1)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gherkin-1.0.4-i386-mswin32 spec/gherkin/parser/parser_spec.rb
gherkin-1.0.4-i386-mingw32 spec/gherkin/parser/parser_spec.rb
gherkin-1.0.4-java spec/gherkin/parser/parser_spec.rb
gherkin-1.0.4 spec/gherkin/parser/parser_spec.rb