Sha256: faf7dea2543200fb3619997239f84c0c3a30847030ee7bdf66ed3e3504318095

Contents?: true

Size: 587 Bytes

Versions: 4

Compression:

Stored size: 587 Bytes

Contents

require 'spec_helper'
module Sexpr::Matcher
  describe Rule, 'match?' do

    let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
    let(:rule){ Rule.new :hello, defn }

    it 'returns true on match' do
      rule.should be_match([:hello, "hello"])
    end

    it 'returns false on partial match' do
      rule.should_not be_match([:hello, "hello", "world"])
    end

    it 'returns false on no match' do
      rule.should_not be_match(["hello"])
      rule.should_not be_match([:hello, 12])
      rule.should_not be_match([])
      rule.should_not be_match(nil)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sexpr-0.5.1 spec/matcher/rule/test_match_q.rb
sexpr-0.5.0 spec/matcher/rule/test_match_q.rb
sexpr-0.4.0 spec/matcher/rule/test_match_q.rb
sexpr-0.3.0 spec/matcher/rule/test_match_q.rb