Sha256: 8bceb6113a23be4657b03576cd7f11e2ed7e9ff5961edcfebdd51b2fe917a449

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

#! /usr/bin/env ruby
# coding: utf-8

require "fileutils"

require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
require "comana/machineinfo.rb"

describe MachineInfo do
  describe "#load_file" do
    context "not exist machineinfo file" do
      DATA_FILE = "spec/machineinfo"
      it { lambda{MachineInfo.load_file(DATA_FILE)}.should_not raise_error}

      mi00 = MachineInfo.load_file(DATA_FILE)
      it {mi00.get_info("SeriesA").should == { "data1" => "A-1", "data2" => "A-2" } }
    end

    context "not exist machineinfo file" do
      it { lambda{ MachineInfo.load_file("") }.should raise_error(Errno::ENOENT) }
    end
  end

  describe "#get_info" do
    before do
      @mi00 = MachineInfo.new({
        "SeriesA" => { "data1" => "A-1", "data2" => "A-2" },
        "SeriesB" => { "data1" => "B-1", "data2" => "B-2" },
      })
    end

    context "mach to hostname in data" do
      subject { @mi00.get_info("SeriesA") }
      it {should == { "data1" => "A-1", "data2" => "A-2" } }
    end

    context "series name + integers" do
      subject { @mi00.get_info("SeriesA00") }
      it {should == { "data1" => "A-1", "data2" => "A-2" } }
    end

    context "series name + alphabet" do
      it {lambda{@mi00.get_info("seriesAB")}.should raise_error(MachineInfo::NoEntryError)}
    end

    context "no entry" do
      it {lambda{@mi00.get_info("")}.should raise_error(MachineInfo::NoEntryError)}
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comana-0.0.9 spec/machineinfo_spec.rb
comana-0.0.8 spec/machineinfo_spec.rb