Sha256: 2dd3867f9565046932e67c7b6d97a8046f097680317d27da88428125b7dc390f

Contents?: true

Size: 764 Bytes

Versions: 13

Compression:

Stored size: 764 Bytes

Contents

require 'spec_helper'

describe ServerMetrics::Disk do
  let(:disk) { ServerMetrics::Disk.new }

  describe '#iostat' do
    it 'uses Disk#diskstats instead @disk_stats' do
      disk.should_receive(:disk_stats).and_return( [] )
      expect {
        disk.send(:iostat, '/dev/chunky')
      }.to_not raise_error
    end
  end

  describe '#disk_stats' do
    it 'returns lines from /proc/diskstats as array' do
      File.should_receive(:readlines).with('/proc/diskstats').
        and_return( %w(chunky bacon) )
      expect(disk.send(:disk_stats)).to eq %w(chunky bacon)
    end

    it 'returns empty array when /proc/diskstats is missing' do
      File.stub(:readlines).and_raise(Errno::ENOENT)
      expect(disk.send(:disk_stats)).to eq []
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
server_metrics-1.2.18 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.14 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.14.pre1 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.14.pre0 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.13 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.12 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.10 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.9.1 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.8 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.7 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.5 spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.5.pre spec/server_metrics/collectors/disk_spec.rb
server_metrics-1.2.4 spec/server_metrics/collectors/disk_spec.rb