Sha256: f8a94275a384b5f68dd99376b9a08bacf82d365440779e7cffa96f33fb391985

Contents?: true

Size: 781 Bytes

Versions: 7

Compression:

Stored size: 781 Bytes

Contents

require 'spec_helper'

describe Parslet::Parser do
  include Parslet
  class FooParser < Parslet::Parser
    rule(:foo) { str('foo') }
    root(:foo)
  end
  
  describe "<- .root" do
    parser = Class.new(Parslet::Parser)
    parser.root :root_parslet
    
    it "should have defined a 'root' method, returning the root" do
      parser_instance = parser.new
      flexmock(parser_instance).should_receive(:root_parslet => :answer)
      
      parser_instance.root.should == :answer
    end 
  end
  it "should parse 'foo'" do
    FooParser.new.parse('foo').should == 'foo'
  end 
  context "composition" do
    let(:parser) { FooParser.new }
    it "should allow concatenation" do
      composite = parser >> str('bar')
      composite.should parse('foobar')
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
parslet-2.0.0 spec/parslet/parser_spec.rb
parslet-1.8.2 spec/parslet/parser_spec.rb
parslet-1.8.1 spec/parslet/parser_spec.rb
parslet-1.8.0 spec/parslet/parser_spec.rb
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/parser_spec.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/parser_spec.rb
parslet-1.7.1 spec/parslet/parser_spec.rb