1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/rubyspec/library/socket/constants/constants_spec.rb
eregon 95e8c48dd3 Add in-tree mspec and ruby/spec
* For easier modifications of ruby/spec by MRI developers.
* .gitignore: track changes under spec.
* spec/mspec, spec/rubyspec: add in-tree mspec and ruby/spec.
  These files can therefore be updated like any other file in MRI.
  Instructions are provided in spec/README.
  [Feature #13156] [ruby-core:79246]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-07 12:04:49 +00:00

90 lines
2.4 KiB
Ruby

require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
include Socket::Constants
describe "Socket::Constants" do
it "defines socket types" do
consts = ["SOCK_DGRAM", "SOCK_RAW", "SOCK_RDM", "SOCK_SEQPACKET", "SOCK_STREAM"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
it "defines protocol families" do
consts = ["PF_INET6", "PF_INET", "PF_UNIX", "PF_UNSPEC"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
platform_is_not :aix do
it "defines PF_IPX protocol" do
Socket::Constants.should have_constant("PF_IPX")
end
end
it "defines address families" do
consts = ["AF_INET6", "AF_INET", "AF_UNIX", "AF_UNSPEC"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
platform_is_not :aix do
it "defines AF_IPX address" do
Socket::Constants.should have_constant("AF_IPX")
end
end
it "defines send/receive options" do
consts = ["MSG_DONTROUTE", "MSG_OOB", "MSG_PEEK"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
it "defines socket level options" do
consts = ["SOL_SOCKET"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
it "defines socket options" do
consts = ["SO_BROADCAST", "SO_DEBUG", "SO_DONTROUTE", "SO_ERROR", "SO_KEEPALIVE", "SO_LINGER",
"SO_OOBINLINE", "SO_RCVBUF", "SO_REUSEADDR", "SO_SNDBUF", "SO_TYPE"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
it "defines multicast options" do
consts = ["IP_ADD_MEMBERSHIP",
"IP_MULTICAST_LOOP", "IP_MULTICAST_TTL"]
platform_is_not :windows do
consts += ["IP_DEFAULT_MULTICAST_LOOP", "IP_DEFAULT_MULTICAST_TTL"]
end
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
platform_is_not :solaris, :windows, :aix do
it "defines multicast options" do
consts = ["IP_MAX_MEMBERSHIPS"]
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
end
it "defines TCP options" do
consts = ["TCP_NODELAY"]
platform_is_not :windows do
consts << "TCP_MAXSEG"
end
consts.each do |c|
Socket::Constants.should have_constant(c)
end
end
end