Sha256: 949551a07f17a94b86b5d29cf0573082c57f35913ce16132686b8d59c9d0098b

Contents?: true

Size: 1.97 KB

Versions: 12

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe Cany::Recipes::Unicorn do
  let(:setup) { proc { use :unicorn } }
  let(:spec) do
    Cany::Specification.new do
      name 'test'
    end
  end
  let(:recipe) { spec.recipes.first }
  let(:system_recipe) { Cany::Dpkg::DebHelperRecipe.new(spec) }
  let(:pre_scripts) { system_recipe.option(:service_pre_scripts) }
  subject { recipe.binary }

  context '#binary' do
    before do
      spec.setup &setup
      spec.system_recipe = system_recipe
      recipe.inner = double('recipe')
      expect(recipe.inner).to receive(:binary)
    end

    context 'without configuration' do

      it 'should launch unicorn only with environment specification and config file' do
        expect(recipe).to receive(:install_service).with(
                              :unicorn,
                              %w(/usr/bin/test unicorn --config-file /etc/test/unicorn.rb --env production),
                              user: 'www-data', group: 'www-data'
                          )
        subject
        expect(pre_scripts).to eq({
                                      mkdir_run: 'mkdir -p /var/run/test',
                                      chown_run: 'chown www-data:www-data /var/run/test'
                                  })
      end
    end

    context 'with defined user/group' do
      let(:setup) { proc { use(:unicorn) { user 'user'; group 'group' } } }

      it 'should launch unicorn with as this user and group' do
        expect(recipe).to receive(:install_service).with(
                              :unicorn,
                              %w(/usr/bin/test unicorn --config-file /etc/test/unicorn.rb --env production),
                              user: 'user', group: 'group'
                          )
        subject
        expect(pre_scripts).to eq({
                                      mkdir_run: 'mkdir -p /var/run/test',
                                      chown_run: 'chown user:group /var/run/test'
                                  })
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cany-0.5.7 spec/cany/recipes/unicorn_spec.rb
cany-0.5.6 spec/cany/recipes/unicorn_spec.rb
cany-0.5.5 spec/cany/recipes/unicorn_spec.rb
cany-0.5.4 spec/cany/recipes/unicorn_spec.rb
cany-0.5.3 spec/cany/recipes/unicorn_spec.rb
cany-0.5.2 spec/cany/recipes/unicorn_spec.rb
cany-0.5.1 spec/cany/recipes/unicorn_spec.rb
cany-0.5.0 spec/cany/recipes/unicorn_spec.rb
cany-0.4.0 spec/cany/recipes/unicorn_spec.rb
cany-0.3.0 spec/cany/recipes/unicorn_spec.rb
cany-0.2.1 spec/cany/recipes/unicorn_spec.rb
cany-0.2.0 spec/cany/recipes/unicorn_spec.rb