Sha256: 2bf906a818f976df02cfc39543c62708f462a6c67cb3feb2089af4d92ca8e117

Contents?: true

Size: 883 Bytes

Versions: 22

Compression:

Stored size: 883 Bytes

Contents

require 'rails_helper'

RSpec.describe Kuroko2::MemoryExpectancy do
  let!(:definition) { create(:job_definition) }
  let!(:instance) { create(:job_instance, job_definition: definition) }
  let!(:expectancy) { described_class.create!(job_definition: definition) }

  describe 'memory expectancy calculation' do
    before { (1..10).each {|i| instance.log_memory_consumption(i) } }

    it 'logs consumptions then calculates expectancy' do
      expect(expectancy.expected_value).to eq(described_class::DEFAULT_VALUE)
      expectancy.calculate!
      expect(expectancy.reload.expected_value).not_to eq(described_class::DEFAULT_VALUE)
    end
  end

  describe '#calculate!' do
    before { (1..10).each {|i| instance.log_memory_consumption(i) } }

    it 'uses max consumption value' do
      expectancy.calculate!
      expect(expectancy.expected_value).to eq(10)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuroko2-0.8.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.7.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.6.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.5.2 spec/models/memory_expectancy_spec.rb
kuroko2-0.5.1 spec/models/memory_expectancy_spec.rb
kuroko2-0.5.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.6 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.5 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.4 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.3 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.2 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.1 spec/models/memory_expectancy_spec.rb
kuroko2-0.4.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.3.4 spec/models/memory_expectancy_spec.rb
kuroko2-0.3.3 spec/models/memory_expectancy_spec.rb
kuroko2-0.3.2 spec/models/memory_expectancy_spec.rb
kuroko2-0.3.1 spec/models/memory_expectancy_spec.rb
kuroko2-0.3.0 spec/models/memory_expectancy_spec.rb
kuroko2-0.2.3 spec/models/memory_expectancy_spec.rb
kuroko2-0.2.2 spec/models/memory_expectancy_spec.rb