File: snapshot_spec.rb

package info (click to toggle)
ruby-vmstat 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 344 kB
  • sloc: ruby: 1,136; ansic: 347; makefile: 3
file content (51 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'spec_helper'

describe Vmstat::Snapshot do
  context "Vmstat#snapshot" do
    let(:snapshot) { Vmstat.snapshot }
    subject { snapshot }

    it "should be an vmstat load snapshot object" do
      should be_a(described_class)
    end

    context "methods" do
      it { should respond_to(:at) }
      it { should respond_to(:boot_time) }
      it { should respond_to(:cpus) }
      it { should respond_to(:disks) }
      it { should respond_to(:load_average) }
      it { should respond_to(:memory) }
      it { should respond_to(:network_interfaces) }
      it { should respond_to(:task) }
    end

    context "content" do
      its(:at) { should be_a(Time) }
      its(:boot_time) { should be_a(Time) }
      its(:cpus) { should be_a(Array) }
      its(:disks) { should be_a(Array) }
      its(:load_average) { should be_a(Vmstat::LoadAverage) }
      its(:memory) { should be_a(Vmstat::Memory) }
      its(:network_interfaces) { should be_a(Array) }
      if RUBY_PLATFORM =~ /darwin|linux/
        its(:task) { should be_a(Vmstat::Task) }
      end

      context "first of cpu" do
        subject { snapshot.cpus.first }
        it { should be_a(Vmstat::Cpu) }
      end
      
      context "first of disks" do
        subject { snapshot.disks.first }
        it { should be_a(Vmstat::Disk) }
      end

      context "first of network interfaces" do
        subject { snapshot.network_interfaces.first }
        it { should be_a(Vmstat::NetworkInterface) }
      end
    end
  end
end