Merge pull request #98 from lautis/erb-in-config-file

Parse and run ERB tags inside YAML config
This commit is contained in:
John Bintz 2011-12-16 06:31:00 -08:00
commit 8465590930
2 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@ require 'coffee-script'
require 'rainbow' require 'rainbow'
require 'yaml' require 'yaml'
require 'erb'
require 'sprockets' require 'sprockets'
@ -112,7 +113,7 @@ module Jasmine
def jasmine_config_data def jasmine_config_data
raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config]) 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 end
end end

View File

@ -37,13 +37,17 @@ describe Jasmine::Headless::Runner do
context 'file exists' do context 'file exists' do
before do before do
File.open(Jasmine::Headless::Runner::RUNNER, 'w') 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 end
it 'should load the jasmine config' do it 'should load the jasmine config' do
runner.jasmine_config['test'].should == 'hello' runner.jasmine_config['test'].should == 'hello'
runner.jasmine_config['spec_dir'].should == 'spec/javascripts' runner.jasmine_config['spec_dir'].should == 'spec/javascripts'
end end
it 'should execute ERB in the config file' do
runner.jasmine_config['erb'].should == 'erb'
end
end end
context 'file does not exist' do context 'file does not exist' do