Sha256: 15e9836068835ff496662de49cb20a574450a1d5b6228b48ac7fe541c32893a5

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

describe Cany::Recipes::Sidekiq do
  let(:spec) do
    Cany::Specification.new do
      name 'test'
    end
  end
  let(:recipe) { spec.recipes.first }

  context '#binary' do
    context 'without configuration' do
      before do
        spec.setup do
          use :sidekiq
        end
      end

      it 'should launch sidekiq only with environment specification' do
        expect(recipe).to receive(:install_service).with(
          :sidekiq,
          %w(/usr/bin/test sidekiq --environment production),
          user: 'www-data', group: 'www-data'
        )
        recipe.inner = double('recipe')
        expect(recipe.inner).to receive(:binary)
        recipe.binary
      end
    end
  end

  context 'with queue names' do
    before do
      spec.setup do
        use :sidekiq do
          queue :name1
          queue :name2
        end
      end
    end

    it 'should launch sidekiq with the list of queues' do
      expect(recipe).to receive(:install_service).with(
        :sidekiq,
        %w(/usr/bin/test sidekiq --environment production --queue name1 --queue name2),
        user: 'www-data', group: 'www-data'
      )
      recipe.inner = double('recipe')
      expect(recipe.inner).to receive(:binary)
      recipe.binary
    end
  end

  context 'with defined user/group' do
    before do
      spec.setup do
        use :sidekiq do
          user 'user'
          group 'group'
        end
      end
    end

    it 'should launch sidekiq with as this user and group' do
      expect(recipe).to receive(:install_service).with(
                            :sidekiq,
                            %w(/usr/bin/test sidekiq --environment production),
                            user: 'user', group: 'group'
                        )
      recipe.inner = double('recipe')
      expect(recipe.inner).to receive(:binary)
      recipe.binary
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cany-0.5.7 spec/cany/recipes/sidekiq_spec.rb
cany-0.5.6 spec/cany/recipes/sidekiq_spec.rb
cany-0.5.5 spec/cany/recipes/sidekiq_spec.rb