Sha256: 439171970df116f2c4c5d04c05bca1a01c0126a6430ffe55ae1bf49ccee96eff
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
require_relative '../test_helper' class Net::TCPClient::Policy::CustomTest < Minitest::Test describe Net::TCPClient::Policy::Custom do describe '#each' do before do @proc = -> addresses, count do addresses[count - 1] end end it 'must return one server, once' do servers = ['localhost:80'] policy = Net::TCPClient::Policy::Custom.new(servers, @proc) collected = [] policy.each { |address| collected << address } assert_equal 1, collected.size address = collected.first assert_equal 80, address.port assert_equal 'localhost', address.host_name assert_equal '127.0.0.1', address.ip_address end it 'must return the servers in the supplied order' do servers = %w(localhost:80 127.0.0.1:2000 lvh.me:2100) policy = Net::TCPClient::Policy::Custom.new(servers, @proc) names = [] policy.each { |address| names << address.host_name } assert_equal %w(localhost 127.0.0.1 lvh.me), names end it 'must handle an empty list of servers' do servers = [] policy = Net::TCPClient::Policy::Custom.new(servers, @proc) names = [] policy.each { |address| names << address.host_name } assert_equal [], names end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
net_tcp_client-2.2.0 | test/policy/custom_policy_test.rb |
net_tcp_client-2.0.1 | test/policy/custom_policy_test.rb |
net_tcp_client-2.0.0 | test/policy/custom_policy_test.rb |