Parse and run ERB tags inside YAML config #98
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user