Sha256: c65f28c3dabef637b0c0538ac4388aae8ef36e8f2429b758c92d8e90317f9c43

Contents?: true

Size: 892 Bytes

Versions: 8

Compression:

Stored size: 892 Bytes

Contents

RSpec.describe WorkerKiller::CountLimiter do
  let(:logger){ Logger.new(nil) }

  subject{ described_class.new(options) }
  let(:min){ rand(50..100) }
  let(:max){ min + rand(100) }
  let(:options){ { min: min, max: max } }

  it { is_expected.to have_attributes(min: min, max: max, limit: a_value_between(min, max), left: subject.limit) }

  it 'expect not to react while less than limit' do
    expect do |b|
      subject.reaction = b.to_proc
      (subject.limit - 1).times do
        expect(subject.check).to be_falsey
      end
    end.not_to yield_control
  end

  it 'expect call reaction when check succeded' do
    (subject.limit - 1).times do
      expect(subject.check).to be_falsey
    end

    expect do |b|
      subject.reaction = b.to_proc
      expect(subject.check).to be_truthy
      expect(subject.check).to be_truthy
    end.to yield_control.exactly(2).times
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
worker_killer-0.1.1.30345 spec/count_limiter_spec.rb
worker_killer-0.1.0.30337 spec/count_limiter_spec.rb
worker_killer-0.1.0.19844 spec/count_limiter_spec.rb
worker_killer-0.1.0.19842 spec/count_limiter_spec.rb
worker_killer-0.1.0.19841 spec/count_limiter_spec.rb
worker_killer-0.1.0.19840 spec/count_limiter_spec.rb
worker_killer-0.1.0.19839 spec/count_limiter_spec.rb
worker_killer-0.0.9.19836 spec/count_limiter_spec.rb