Sha256: 9170d922572c2413ac4be7f5f1a9566bcc9ca70e9772702a6d7d365e0d6386fb

Contents?: true

Size: 693 Bytes

Versions: 5

Compression:

Stored size: 693 Bytes

Contents

require "spec_helper"

shared_examples_for Massive::MemoryConsumption do
  let(:memory) { 123456 }
  let(:io) { double(IO, gets: "    #{memory} ") }
  before { IO.stub(:popen).with("ps -o rss= -p #{Process.pid}").and_yield(io) }

  its(:current_memory_consumption) { should eq(memory) }

  context "and an error is raised" do
    let(:error) { StandardError.new('some error') }
    before { IO.stub(:popen).with("ps -o rss= -p #{Process.pid}").and_raise(error) }

    its(:current_memory_consumption) { should be_zero }
  end
end

describe Massive::Step do
  it_should_behave_like Massive::MemoryConsumption
end

describe Massive::Job do
  it_should_behave_like Massive::MemoryConsumption
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
massive-0.4.0 spec/models/massive/memory_consumption_spec.rb
massive-0.3.0 spec/models/massive/memory_consumption_spec.rb
massive-0.2.0 spec/models/massive/memory_consumption_spec.rb
massive-0.1.1 spec/models/massive/memory_consumption_spec.rb
massive-0.1.0 spec/models/massive/memory_consumption_spec.rb