(spec) Add format spec test

This commit is contained in:
Brian Cain 2015-10-21 22:21:13 -07:00
parent ac12ea69c1
commit b62cffa2cd
3 changed files with 20 additions and 2 deletions

View file

@ -64,7 +64,7 @@ class Vmfloaty
unless os_types.nil? unless os_types.nil?
response = Pooler.retrieve(verbose, os_types, token, url) response = Pooler.retrieve(verbose, os_types, token, url)
Format.get_hosts(response) puts Format.get_hosts(response)
else else
puts 'You did not provide an OS to get' puts 'You did not provide an OS to get'
end end

View file

@ -14,6 +14,6 @@ class Format
end end
end end
puts host_hash.to_json host_hash.to_json
end end
end end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
require 'json'
require_relative '../../lib/vmfloaty/format'
describe Pooler do
describe "#get_hosts" do
before :each do
@hostname_hash = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"]},\"debian-7-x86_64\":{\"hostname\":\"zb91y9qbrbf6d3q\"},\"domain\":\"company.com\"}"
@format_hash = "{\"debian-7-i386\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"],\"debian-7-x86_64\":\"zb91y9qbrbf6d3q\",\"domain\":\"company.com\"}"
end
it "formats a hostname hash into os, hostnames, and domain name" do
expect(Format.get_hosts(JSON.parse(@hostname_hash))).to eq @format_hash
end
end
end