Sha256: a43c681a40315e089a3ae2c4884e17935d2459ea9027aeab1796ccbbb069b189

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

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

module Gherkin
  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

Version data entries

4 entries across 4 versions & 1 rubygems

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