Sha256: 072f0ad0964b0c826ba07a12ed64ed8e6463f3e92f65d4c87013a84bba8c496a

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Dockly::Foreman do
  describe '#create!' do
    subject do
      Dockly::Foreman.new do
        name :foreman
        init_dir '/etc/systemd/system'
        build_dir 'build/foreman'
        procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
        user 'root'
        type 'systemd'
        prefix '/bin/sh'
      end
    end

    [:init_dir, :build_dir, :procfile, :user, :type].each do |ivar|
      context "when the #{ivar} is nil" do
        before { subject.instance_variable_set(:"@#{ivar}", nil) }

        it 'raises an error' do
          expect { subject.create! }.to raise_error
        end
      end
    end

    context 'when all of the required variables are present' do
      it 'makes the upstart scripts' do
        subject.create!
        File.exist?('build/foreman/foreman.target').should be_true
        File.exist?('build/foreman/foreman-web.target').should be_true
        File.exist?('build/foreman/foreman-web@.service').should be_true
        File.open('build/foreman/foreman-web@.service')
            .grep(/^ExecStart=\/bin\/bash -lc 'exec \/bin\/sh start_my_server'$/)
            .length.should == 1
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dockly-4.4.1 spec/dockly/foreman_spec.rb
dockly-4.4.0 spec/dockly/foreman_spec.rb
dockly-4.3.0 spec/dockly/foreman_spec.rb
dockly-4.2.0 spec/dockly/foreman_spec.rb
dockly-4.1.0 spec/dockly/foreman_spec.rb
dockly-4.0.0 spec/dockly/foreman_spec.rb
dockly-3.4.1 spec/dockly/foreman_spec.rb
dockly-3.4.0 spec/dockly/foreman_spec.rb