# Copyright (C) 2011 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 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 invalidate non-existent configurator' do lang = RightConf::Language.parse('toto { 42 }') lang.validation_errors.size.should == 1 lang.validation_errors.first.should == "Unknown configurator 'toto'" end it 'should parse correctly' do lang = RightConf::Language.parse('ruby { ruby_version "1"; rubygems_version "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 == { :ruby_version => '1', :rubygems_version => '2' } end it 'should parse multiple configurations' do lang = RightConf::Language.parse(<<-EOS ruby do ruby_version "1" rubygems_version "2" end bundler do bundler_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 == { :ruby_version => '1', :rubygems_version => '2' } lang.configurators[1].class.should == RightConf::BundlerConfigurator lang.configurators[1].instance_variable_get(:@settings_values).should == { :bundler_version => '3' } end end