Sha256: 3d2cd77d0ebcea33032fd5f2c7cb14a2f3fd0d745e8011a79b14f2ac9a46bdc7

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

require 'spec_helper'
module Qrb
  describe Syntax, "named_constraint" do

    subject{
      Syntax.parse(input, root: "named_constraint")
    }

    let(:compiled){
      subject.compile("a")
    }

    context 'a >= 10' do
      let(:input){ 'foo: a >= 10' }

      it 'compiles to an Hash' do
        compiled.should be_a(Hash)
      end

      it 'has expected keys' do
        compiled.keys.should eq([:foo])
      end

      it 'should be the correct Proc' do
        compiled[:foo].call(12).should be_true
        compiled[:foo].call(9).should be_false
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qrb-0.2.0 spec/unit/syntax/nodes/test_named_constraint.rb
qrb-0.1.0 spec/unit/syntax/nodes/test_named_constraint.rb