Sha256: 2ca4c94e9dce6c8d63f9af5cb939e5029c503f398e69b07cd715f6db2a1280e3

Contents?: true

Size: 987 Bytes

Versions: 18

Compression:

Stored size: 987 Bytes

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

18 entries across 18 versions & 1 rubygems

Version Path
gherkin-1.0.2-i386-mswin32 spec/gherkin/parser_spec.rb
gherkin-1.0.2-i386-mingw32 spec/gherkin/parser_spec.rb
gherkin-1.0.2-java spec/gherkin/parser_spec.rb
gherkin-1.0.2 spec/gherkin/parser_spec.rb
gherkin-1.0.1-i386-mswin32 spec/gherkin/parser_spec.rb
gherkin-1.0.1-i386-mingw32 spec/gherkin/parser_spec.rb
gherkin-1.0.1-universal-java-1.5 spec/gherkin/parser_spec.rb
gherkin-1.0.1 spec/gherkin/parser_spec.rb
gherkin-1.0.0-i386-mingw32 spec/gherkin/parser_spec.rb
gherkin-1.0.0-i386-mswin32 spec/gherkin/parser_spec.rb
gherkin-1.0.0-universal-java-1.5 spec/gherkin/parser_spec.rb
gherkin-1.0.0 spec/gherkin/parser_spec.rb
gherkin-0.0.4-universal-java-1.5 spec/gherkin/parser_spec.rb
gherkin-0.0.4-i386-mswin32 spec/gherkin/parser_spec.rb
gherkin-0.0.4-i386-mingw32 spec/gherkin/parser_spec.rb
gherkin-0.0.4 spec/gherkin/parser_spec.rb
gherkin-0.0.3-universal-java-1.5 spec/gherkin/parser_spec.rb
gherkin-0.0.3 spec/gherkin/parser_spec.rb