Sha256: 2f14c952b379d44cc0ca64a321f66445da92e95bad065431f27b5fdd9545c625

Contents?: true

Size: 1.79 KB

Versions: 8

Compression:

Stored size: 1.79 KB

Contents

require_relative './rivet_spec_setup'

include SpecHelpers

describe 'rivet bootstrap' do
  let (:bootstrap) { Rivet::Bootstrap.new(SpecHelpers::AUTOSCALE_DEF['bootstrap']) }
  let (:bootstrap_def) { SpecHelpers::AUTOSCALE_DEF['bootstrap'] }

  tempdir_context 'with all necessary files in place' do
    before do


      validator_file = File.join(
        bootstrap_def['config_dir'],
        "#{bootstrap_def['environment']}-validator.pem")

      template_dir = File.join(
        bootstrap_def['config_dir'],
        Rivet::Bootstrap::TEMPLATE_SUB_DIR)

      template_file = File.join(template_dir,bootstrap_def['template'])

      FileUtils.mkdir_p(bootstrap_def['config_dir'])
      FileUtils.mkdir_p(template_dir)
      File.open(template_file,'w') { |f| f.write(SpecHelpers::BOOTSTRAP_TEMPLATE) }
      FileUtils.touch(validator_file)
    end

    describe "#user_data" do
      it 'returns a string that contains the chef organization' do
        org = bootstrap_def['organization']
        bootstrap.user_data.should =~ /chef_server_url\s*.*#{org}.*/
      end

      it 'returns a string that contains the environment' do
        env = bootstrap_def['env']
        bootstrap.user_data.should =~ /environment\s*.*#{env}.*/
      end

      it 'returns a string that contains the run_list as json' do
        run_list = { :run_list => bootstrap_def['run_list'].join(",") }.to_json
        bootstrap.user_data.should =~ /#{run_list}/
      end

      it 'returns a string that contains each gem to install' do
        bootstrap_def['gems'].each do |g|
          if g.size > 1
            gem_regexp = /gem\s*install\s*#{g[0]}.*#{g[1]}/
          else
            gem_regexp = /gem\s*install\s*#{g[0]}/
          end
          bootstrap.user_data.should =~ gem_regexp
        end
      end

    end

  end

end









Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rivet-1.0.7 spec/rivet_bootstrap_spec.rb
rivet-1.0.6 spec/rivet_bootstrap_spec.rb
rivet-1.0.5 spec/rivet_bootstrap_spec.rb
rivet-1.0.4 spec/rivet_bootstrap_spec.rb
rivet-1.0.3 spec/rivet_bootstrap_spec.rb
rivet-1.0.2 spec/rivet_bootstrap_spec.rb
rivet-1.0.1 spec/rivet_bootstrap_spec.rb
rivet-1.0.0 spec/rivet_bootstrap_spec.rb