Sha256: 3ff0ba7e5845e04ea571c43e092b51210ca5383f5a4616fb70679896e12d4cb4

Contents?: true

Size: 479 Bytes

Versions: 5

Compression:

Stored size: 479 Bytes

Contents

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

    let(:grammar){ {:hello => Terminal.new(/^[a-z]+$/)} }
    let(:rule)   { Reference.new :hello, grammar        }

    it 'returns true on match' do
      rule.should be_match("hello")
      (rule === "hello").should be_true
    end

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

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sexpr-0.6.0 spec/unit/matcher/reference/test_match_q.rb
sexpr-0.5.1 spec/matcher/reference/test_match_q.rb
sexpr-0.5.0 spec/matcher/reference/test_match_q.rb
sexpr-0.4.0 spec/matcher/reference/test_match_q.rb
sexpr-0.3.0 spec/matcher/reference/test_match_q.rb