Sha256: 6f809242ef6d63555047c7dfd0efcbf7195e28b20922a8e13befe3932dc6b716

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'path'
$root_folder ||= Path.backfind('.[Rakefile]')

# Require wlang
$LOAD_PATH.unshift(($root_folder/:lib).to_s)
require 'wlang'

# RSpec helpers
require 'rspec'
module Helpers
  include WLang
  extend(self)

  def root_folder
    $root_folder
  end

  def spec_folder
    root_folder/:spec
  end

  def fixtures_folder
    spec_folder/:fixtures
  end

  def tpl_path(what)
    what = "#{what}.wlang" if what.is_a?(Symbol)
    fixtures_folder/:templates/what
  end

  def tpl(what)
    tpl_path(what).read
  end

  # Load fixture dialects
  spec_folder.glob("fixtures/dialect/*.rb").each do |f|
    require f.expand_path
  end

  # Install helper methods for templates
  fixtures_folder.glob("templates/*.wlang").each do |f|
    name = f.basename.without_extension
    define_method(:"#{name}_path") do
      fixtures_folder/:templates/f.basename
    end
    define_method(:"#{name}_tpl") do
      send(:"#{name}_path").read
    end
    define_method(:"#{name}_io") do |&b|
      send(:"#{name}_path").open("r") do |io|
        b.call(io)
      end
    end
  end

end
include Helpers

# Configure rspec
RSpec.configure do |c|
  c.include Helpers
  c.filter_run_excluding :hash_ordering => (RUBY_VERSION < "1.9")
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlang-3.0.0 spec/spec_helper.rb