File: ignored_spec.rb

package info (click to toggle)
ruby-parslet 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,260 kB
  • sloc: ruby: 6,157; sh: 8; javascript: 3; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'spec_helper'

describe Parslet::Atoms::Ignored do
  include Parslet

  describe "ignore" do
    it "ignores parts of the input" do
      str('a').ignore.parse('a').should == nil
      (str('a') >> str('b').ignore >> str('c')).parse('abc').should == 'ac'
      (str('a') >> str('b').as(:name).ignore >> str('c')).parse('abc').should == 'ac'
      (str('a') >> str('b').maybe.ignore >> str('c')).parse('abc').should == 'ac'
      (str('a') >> str('b').maybe.ignore >> str('c')).parse('ac').should == 'ac'
    end
  end
end