Sha256: f882d53a2923b651aadb316330a7815f760215b909107bba67430ae388f82f3f

Contents?: true

Size: 404 Bytes

Versions: 4

Compression:

Stored size: 404 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

4 entries across 4 versions & 1 rubygems

Version Path
sexpr-0.5.1 spec/matcher/terminal/test_eat.rb
sexpr-0.5.0 spec/matcher/terminal/test_eat.rb
sexpr-0.4.0 spec/matcher/terminal/test_eat.rb
sexpr-0.3.0 spec/matcher/terminal/test_eat.rb