Sha256: 1655c32fc78940c396e5482bf9ffbea540abe871e0ba7847b9e37a1abc8ae9eb

Contents?: true

Size: 405 Bytes

Versions: 3

Compression:

Stored size: 405 Bytes

Contents

require 'spec_helper'
module Sexpr::Matcher
  describe Terminal, "eat" do

    let(:rule){ Terminal.new(/^[a-z]+$/) }

    context "with a regexp" do

      it 'returns subarray when match' do
        rule.eat(["hello", "world"]).should eq(["world"])
      end

      it 'returns nil when no match' do
        rule.eat([]).should be_nil
        rule.eat(["12"]).should be_nil
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sexpr-1.1.0 spec/unit/matcher/terminal/test_eat.rb
sexpr-1.0.0 spec/unit/matcher/terminal/test_eat.rb
sexpr-0.6.0 spec/unit/matcher/terminal/test_eat.rb