Sha256: 85a05968f155d6e1b307a127fa16c21d663934d5f200623a6e172f5b316ed35a

Contents?: true

Size: 883 Bytes

Versions: 7

Compression:

Stored size: 883 Bytes

Contents

require 'spec_helper'

describe Parslet do
  include Parslet
  
  describe Parslet::ParseFailed do
    it "should be caught by an empty rescue" do
      begin
        raise Parslet::ParseFailed
      rescue
        # Success! Ignore this.
      end
    end 
  end
  describe "<- .rule" do
    # Rules define methods. This can be easily tested by defining them right 
    # here. 
    context "empty rule" do
      rule(:empty) { }
      
      it "should raise a NotImplementedError" do
        lambda {
          empty.parslet
        }.should raise_error(NotImplementedError)
      end 
    end
    
    context "containing 'any'" do
      rule(:any_rule) { any }
      subject { any_rule }
      
      it { should be_a Parslet::Atoms::Entity }
      it "should memoize the returned instance" do
        any_rule.object_id.should == any_rule.object_id
      end 
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

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