Sha256: ed49e6708ea717e70035c645ef057d53b86b0aae98035bc45f9e26b5562b08cd

Contents?: true

Size: 1.16 KB

Versions: 163

Compression:

Stored size: 1.16 KB

Contents

describe KnapsackPro::Config::EnvGenerator do
  describe '.set_queue_id' do
    subject { described_class.set_queue_id }

    context 'when queue id exists' do
      before do
        stub_const("ENV", { 'KNAPSACK_PRO_QUEUE_ID' => 'fake-queue-id' })
      end

      it do
        expect { subject }.to raise_error('Queue ID already generated.')
      end
    end

    context "when queue id doesn't exist" do
      before { stub_const("ENV", {}) }

      it do
        subject
        expect(ENV['KNAPSACK_PRO_QUEUE_ID']).not_to be_nil
      end

      it do
        now = DateTime.new(2016, 1, 9, 0, 0, 0)

        Timecop.freeze(now) do
          uuid = 'fake-uuid'
          expect(SecureRandom).to receive(:uuid).and_return(uuid)

          subject

          expect(ENV['KNAPSACK_PRO_QUEUE_ID']).to eq '1452297600_fake-uuid'
        end
      end
    end
  end

  describe '.set_subset_queue_id' do
    subject { described_class.set_subset_queue_id }

    before { stub_const("ENV", {}) }

    it do
      uuid = 'fake-uuid'
      expect(SecureRandom).to receive(:uuid).and_return(uuid)

      subject

      expect(ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID']).to eq uuid
    end
  end
end

Version data entries

163 entries across 163 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.12.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.12.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.11.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.10.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.9.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.8.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.8.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.8.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.7.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.6.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.6.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.6.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.1.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.0.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-7.0.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-6.0.4 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-6.0.3 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-6.0.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-6.0.1 spec/knapsack_pro/config/env_generator_spec.rb