serverspec/serverspec

View on GitHub
lib/serverspec/matcher/be_reachable.rb

Summary

Maintainability
A
0 mins
Test Coverage
RSpec::Matchers.define :be_reachable  do
  match do |host|
    proto   = 'tcp'
    timeout = 5
    if @attr
      port    = @attr[:port]
      proto   = @attr[:proto]   if @attr[:proto]
      timeout = @attr[:timeout] if @attr[:timeout]
    end

    host.reachable?(port, proto, timeout)
  end

  chain :with do |attr|
    @attr = attr
  end
end