Sha256: e36f125584885215ac5536242820d6a21006ee6919871a01a1d076359d24e394

Contents?: true

Size: 1.64 KB

Versions: 16

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

module Beaker
  module Shared
    describe HostRoleParser do
      let( :host_handler )   { Beaker::Shared::HostRoleParser }
      let( :platform )       { @platform || 'unix' }
      let( :hosts )          { hosts = make_hosts( { :platform => platform } )
                               hosts[0][:roles] = ['agent']
                               hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
                               hosts[2][:roles] = ['agent']
                               hosts }

      context "hosts_with_role" do
        it "can find the master in a set of hosts" do

          expect( host_handler.hosts_with_role( hosts, 'master' ) ).to be === [hosts[1]]

        end

        it "can find all agents in a set of hosts" do

          expect( host_handler.hosts_with_role( hosts, 'agent' ) ).to be === hosts

        end

        it "returns [] when no match is found in a set of hosts" do

          expect( host_handler.hosts_with_role( hosts, 'surprise' ) ).to be === []

        end

      end

      context "only_host_with_role" do
        it "can find the single master in a set of hosts" do

          expect( host_handler.only_host_with_role( hosts, 'master' ) ).to be === hosts[1]

        end

        it "throws an error when more than one host with matching role is found" do

          expect{ host_handler.only_host_with_role( hosts, 'agent' ) }.to raise_error(ArgumentError)

        end

        it "throws an error when no host is found matching the role" do

          expect{ host_handler.only_host_with_role( hosts, 'surprise' ) }.to raise_error(ArgumentError)

        end
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-1.16.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.15.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.14.1 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.14.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.13.1 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.13.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.12.2 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.12.1 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.12.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.11.2 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.11.1 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.11.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.10.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.9.1 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.9.0 spec/beaker/shared/host_role_parser_spec.rb
beaker-1.8.2 spec/beaker/shared/host_role_parser_spec.rb