Sha256: 1a5c8ef46787ca9962656a7eb91996e4f76db375220ac7c3402ef287aa735f0a

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
module Sexpr
  describe Sexpr, "load" do

      subject{ Sexpr.load(arg) }

      after do
        subject.should be_a(Grammar)
        subject[:bool_expr].should be_a(Matcher::Alternative)
      end

      context "on a YAML path" do
        let(:arg){ fixtures_path/"bool_expr.sexp.yml" }

        it 'sets the path on the grammar' do
          subject.path.should eq(arg)
        end

        it 'finds the parser with the relative path' do
          subject.parser.should be_a(Parser::Citrus)
        end

      end # grammar.yml

      context "on a YAML path as a String" do
        let(:arg){ (fixtures_path/"bool_expr.sexp.yml").to_s }

        it 'sets the path on the grammar' do
          subject.path.should eq(arg)
        end

        it 'finds the parser with the relative path' do
          subject.parser.should be_a(Parser::Citrus)
        end

      end # grammar.yml

      context 'with an explicit Hash' do
        let(:arg){ {:rules => {:bool_expr => [true, false]}} }

        it 'does not set a path' do
          subject.path.should be_nil
        end

      end

      context 'with a String' do
        let(:arg){
          <<-YAML
            rules:
              bool_expr: [true, false]
          YAML
        }

        it 'does not set a path' do
          subject.path.should be_nil
        end

      end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sexpr-0.5.1 spec/test_load.rb
sexpr-0.5.0 spec/test_load.rb
sexpr-0.4.0 spec/test_load.rb
sexpr-0.3.0 spec/test_load.rb