Sha256: a6bb59a5e04a927f2014be45bcb52fff2687575b654066a10738fda451cbc784

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'gisele-language'

module SpecHelpers

  def parse(text, rule, consume = true)
    grammar = Gisele::Language::Grammar
    grammar.parse(text, :root => rule, :consume => consume)
  end

  def ast(text, rule, consume = true)
    ast = parse(text, rule, consume).to_ast
    unless sexp_grammar[rule] === ast
      raise "expected #{ast} to match #{rule} (#{text})"
    end
    ast
  end

  def fixtures_dir
    (Path.dir/:fixtures)
  end

  def fixture_files(glob)
    fixtures_dir.glob(glob)
  end

  def sexp_grammar
    Gisele::Language
  end

  def simple_ast
    Gisele::ast(fixtures_dir/:tasks/"simple.gis")
  end

  def complete_ast
    Gisele::ast(fixtures_dir/:tasks/"complete.gis")
  end

end

RSpec.configure do |c|
  c.include SpecHelpers
  c.extend  SpecHelpers
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gisele-language-0.6.0 spec/spec_helper.rb
gisele-language-0.5.1 spec/spec_helper.rb
gisele-language-0.5.0 spec/spec_helper.rb