Sha256: 942174e552100a394c76e5c12a2b9182db20ddecf73fa829d4c29dabf471e0cf

Contents?: true

Size: 1.65 KB

Versions: 57

Compression:

Stored size: 1.65 KB

Contents

require "spec_helper"

module Beaker
  module Options
    describe HostsFileParser do

      let(:parser)      {HostsFileParser}
      let(:filepath)    {File.join(File.expand_path(File.dirname(__FILE__)), "data", "hosts.cfg")}

      it "can correctly read a host file" do
        FakeFS.deactivate!
        config = parser.parse_hosts_file(filepath)
        expect(config).to be === {:HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :consoleport=>443}
      end

      it "can merge CONFIG section into overall hash" do
        FakeFS.deactivate!
        config = parser.parse_hosts_file(filepath)
        expect(config['CONFIG']).to be === nil
        expect(config['consoleport']).to be === 443
      end

      it "returns empty configuration when no file provided" do
        FakeFS.deactivate!
        expect(parser.parse_hosts_file()).to be === { :HOSTS => {} }
      end

      it "raises an error on no file found" do
        FakeFS.deactivate!
        expect{parser.parse_hosts_file("not a valid path")}.to raise_error(ArgumentError)
      end

      it "raises an error on bad yaml file" do
        FakeFS.deactivate!
        allow( YAML ).to receive(:load_file) { raise Psych::SyntaxError }
        allow( File ).to receive(:exists?).and_return(true)
        expect { parser.parse_hosts_file("not a valid path") }.to raise_error(ArgumentError)
      end

    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
beaker-2.44.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.43.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.42.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.41.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.40.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.39.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.38.1 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.38.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.37.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.36.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.35.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.34.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.33.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.32.1 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.32.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.31.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.30.1 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.30.0 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.29.1 spec/beaker/options/hosts_file_parser_spec.rb
beaker-2.29.0 spec/beaker/options/hosts_file_parser_spec.rb