Sha256: fa2f95ce96832cb858e8f05e558119feb8f971dd3535304abf7082466bd5ce99

Contents?: true

Size: 1.9 KB

Versions: 55

Compression:

Stored size: 1.9 KB

Contents

describe KnapsackPro::Hooks::Queue do
  describe '.call_before_queue' do
    subject { described_class.call_before_queue }

    context 'when callback is not set' do
      before do
        described_class.reset_before_queue
      end

      it { should be_nil }
    end

    context 'when callback is set' do
      let(:queue_id) { double }

      before do
        expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)

        described_class.before_queue do |q_id|
          [:fake_value, q_id]
        end
      end

      it { should eq [:fake_value, queue_id] }
    end
  end

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

    context 'when callback is not set' do
      before do
        described_class.reset_after_subset_queue
      end

      it { should be_nil }
    end

    context 'when callback is set' do
      let(:queue_id) { double }
      let(:subset_queue_id) { double }

      before do
        expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
        expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)

        described_class.after_subset_queue do |q_id, subset_q_id|
          [:fake_value, q_id, subset_q_id]
        end
      end

      it { should eq [:fake_value, queue_id, subset_queue_id] }
    end
  end

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

    context 'when callback is not set' do
      before do
        described_class.reset_after_queue
      end

      it { should be_nil }
    end

    context 'when callback is set' do
      let(:queue_id) { double }

      before do
        expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)

        described_class.after_queue do |q_id|
          [:fake_value, q_id]
        end
      end

      it { should eq [:fake_value, queue_id] }
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
knapsack_pro-2.1.1 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-2.1.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-2.0.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.22.3 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.22.2 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.22.1 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.22.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.21.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.20.2 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.20.1 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.20.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.19.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.18.2 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.18.1 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.18.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.17.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.16.1 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.16.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.15.0 spec/knapsack_pro/hooks/queue_spec.rb
knapsack_pro-1.14.0 spec/knapsack_pro/hooks/queue_spec.rb