Sha256: c476d272770332f4703e35ceb8c24a252bd946744b580287000d912e7c08b7b1
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 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" #DATA_FILE = "spec/dummy.yaml" #data = { # "Host1" => { "data1" => "1-1", "data2" => "1-2" }, # "Host2" => { "data1" => "2-1", "data2" => "2-2" }, #} #io = File.open(DATA_FILE, "w") #YAML.dump(data, io) #io.close #pp File.open(DATA_FILE, "r").readlines it { lambda{MachineInfo.load_file(DATA_FILE)}.should_not raise_error} mi00 = MachineInfo.load_file(DATA_FILE) it {mi00.get_host("Host1").should == { "data1" => "1-1", "data2" => "1-2" } } #FileUtils.rm DATA_FILE end context "not exist machineinfo file" do it { lambda{ MachineInfo.load_file("") }.should raise_error(Errno::ENOENT) } end end describe "#get_host" do before do @mi00 = MachineInfo.new({ "Host1" => { "data1" => "1-1", "data2" => "1-2" }, "Host2" => { "data1" => "2-1", "data2" => "2-2" }, }) end context "exist in data" do subject { @mi00.get_host("Host1") } it {should == { "data1" => "1-1", "data2" => "1-2" } } end context "no entry" do it {lambda{@mi00.get_host("")}.should raise_error(MachineInfo::NoEntryError)} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comana-0.0.5 | spec/machineinfo_spec.rb |