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-2.1.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-2.1.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-2.0.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.22.3 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.22.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.22.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.22.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.21.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.20.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.20.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.20.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.19.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.18.2 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.18.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.18.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.17.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.16.1 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.16.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.15.0 spec/knapsack_pro/config/env_generator_spec.rb
knapsack_pro-1.14.0 spec/knapsack_pro/config/env_generator_spec.rb