# Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide. # # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, # reproduction, modification, or disclosure of this program is # strictly prohibited. Any use of this program by an authorized # licensee is strictly subject to the terms and conditions, # including confidentiality obligations, set forth in the applicable # License Agreement between RightScale.com, Inc. and # the licensee require File.join(File.dirname(__FILE__), 'spec_helper') describe RightConf::Language do before(:all) do # Disable overrides RightConf::OverridesLanguage.instance_variable_set(:@overrides, {}) end after(:all) do RightConf::OverridesLanguage.instance_variable_set(:@overrides, nil) end it 'should invalidate missing blocks' do lang = RightConf::Language.parse('toto') lang.validation_errors.size.should == 1 lang.validation_errors.first.should == "Invalid syntax, expecting block after 'toto'" end it 'should warn about non-existent configurator' do lang = RightConf::Language.parse('toto { 42 }') lang.warnings.size.should == 1 lang.warnings.first.should == "Unknown configurator 'toto'" end it 'should parse correctly' do lang = RightConf::Language.parse('ruby { version "1"; rubygems "2" }') lang.validation_errors.size.should == 0 lang.configurators.size.should == 1 lang.configurators.first.class.should == RightConf::RubyConfigurator lang.configurators.first.instance_variable_get(:@settings_values).should == { 'version' => '1', 'rubygems' => '2' } end it 'should parse multiple configurations' do lang = RightConf::Language.parse(<<-EOS ruby do version "1" rubygems "2" end bundler do version "3" end EOS ) lang.validation_errors.size.should == 0 lang.configurators.size.should == 2 lang.configurators[0].class.should == RightConf::RubyConfigurator lang.configurators[0].instance_variable_get(:@settings_values).should == { 'version' => '1', 'rubygems' => '2' } lang.configurators[1].class.should == RightConf::BundlerConfigurator lang.configurators[1].instance_variable_get(:@settings_values).should == { 'version' => '3' } end end