From 4c7a1f860d3c3036a4efaa7cf260cb85e66c5eb4 Mon Sep 17 00:00:00 2001 From: Ville Lautanala Date: Fri, 16 Dec 2011 14:21:06 +0200 Subject: [PATCH] Parse and run ERB tags inside YAML config --- lib/jasmine/headless/runner.rb | 3 ++- spec/lib/jasmine/headless/runner_spec.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jasmine/headless/runner.rb b/lib/jasmine/headless/runner.rb index 1337123..85763c8 100644 --- a/lib/jasmine/headless/runner.rb +++ b/lib/jasmine/headless/runner.rb @@ -4,6 +4,7 @@ require 'coffee-script' require 'rainbow' require 'yaml' +require 'erb' require 'sprockets' @@ -112,7 +113,7 @@ module Jasmine def jasmine_config_data raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config]) - YAML.load_file(@options[:jasmine_config]) + YAML.load(ERB.new(File.read(@options[:jasmine_config])).result(binding)) end end end diff --git a/spec/lib/jasmine/headless/runner_spec.rb b/spec/lib/jasmine/headless/runner_spec.rb index 6c2787c..d6e4cd2 100644 --- a/spec/lib/jasmine/headless/runner_spec.rb +++ b/spec/lib/jasmine/headless/runner_spec.rb @@ -37,13 +37,17 @@ describe Jasmine::Headless::Runner do context 'file exists' do before do File.open(Jasmine::Headless::Runner::RUNNER, 'w') - File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello') } + File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello', 'erb' => '<%= "erb" %>') } end it 'should load the jasmine config' do runner.jasmine_config['test'].should == 'hello' runner.jasmine_config['spec_dir'].should == 'spec/javascripts' end + + it 'should execute ERB in the config file' do + runner.jasmine_config['erb'].should == 'erb' + end end context 'file does not exist' do