net-proto 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43aeb8ae73964b0d03c6897ecf87b6e41cc1b5728976c9d40765d0965ce3038b
4
- data.tar.gz: b819851e28b890bb5545017e6da3706eec374116f94a0b9abf90334cd94c1562
3
+ metadata.gz: 22fc633cd0a57112a8a74a3725ef8cf228a0e4d7234d092b154bd075fb6467e3
4
+ data.tar.gz: d1b70a57d424a8a9f8088c38f3551fd339ed9ba35b701de4d53354358555cee7
5
5
  SHA512:
6
- metadata.gz: 6120909386e31c152f93c7905549a7b10332f731f9d99677d1908c96322c6f864002aab62e4f89e02f00d0a5a556d0949dfe30b1fb708d28c4b752cd7db50724
7
- data.tar.gz: 5b77d5ea65999cb40b588d1f1a0f0d59de71d18db4baf5379523fb419affe8ddecec332928a83ee17b89ba207a0bc9f8f4a5d94616fa0cffa2efbd3377214b38
6
+ metadata.gz: 7bb84b41f65803a273e6343d3a2e6d7126a2589831529120bbd255b6fcae57e642ea76d1976bd4f44287be0ededc5941f9393136d2b3429558e1b63174101934
7
+ data.tar.gz: 0a9abc6743751706c141314275595f2162f69924ee4b8a63dd14a6fff9caa2f0a66edfa855031e9e563b62408b351e81afb012889355564e79bc807134eac2b0
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.4.0 - 17-Aug-2020
2
+ * Switched from test-unit to rspec.
3
+
1
4
  == 1.3.1 - 30-Jul-2020
2
5
  * Add a LICENSE file as required by the Apache-2.0 license.
3
6
 
data/MANIFEST CHANGED
@@ -13,4 +13,4 @@
13
13
  * lib/linux/net/proto.rb
14
14
  * lib/sunos/net/proto.rb
15
15
  * examples/example_net_proto.rb
16
- * test/test_net_proto.rb
16
+ * spec/net_proto_spec.rb
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/clean'
4
+ require 'rspec/core/rake_task'
4
5
 
5
6
  CLEAN.include('**/*.gem', '**/*.rbx', '**/*.rbc')
6
7
 
@@ -25,9 +26,8 @@ task :example do
25
26
  ruby '-Ilib examples/example_net_proto.rb'
26
27
  end
27
28
 
28
- Rake::TestTask.new do |t|
29
- t.warning = true
30
- t.verbose = true
29
+ RSpec::Core::RakeTask.new(:spec) do |t|
30
+ t.pattern = ['spec/net_proto_spec.rb']
31
31
  end
32
32
 
33
- task :default => :test
33
+ task :default => :spec
@@ -5,7 +5,7 @@ module Net
5
5
  extend FFI::Library
6
6
 
7
7
  # The version of the net-proto library
8
- VERSION = '1.3.1'.freeze
8
+ VERSION = '1.4.0'.freeze
9
9
 
10
10
  private_class_method :new
11
11
 
@@ -2,20 +2,20 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'net-proto'
5
- spec.version = '1.3.1'
5
+ spec.version = '1.4.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/net-proto'
10
10
  spec.summary = 'A Ruby interface for determining protocol information'
11
- spec.test_file = 'test/test_net_proto.rb'
11
+ spec.test_file = 'spec/net_proto_spec.rb'
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = Dir['certs/*']
14
14
 
15
15
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/netproto.txt']
16
16
 
17
- spec.add_dependency('ffi', '>= 1.0')
18
- spec.add_development_dependency('test-unit', '>= 2.2')
17
+ spec.add_dependency('ffi', '~> 1.0')
18
+ spec.add_development_dependency('rspec', '~> 3.9')
19
19
  spec.add_development_dependency('rake')
20
20
 
21
21
  spec.metadata = {
@@ -0,0 +1,123 @@
1
+ ###########################################################################
2
+ # net_netproto_spec.rb
3
+ #
4
+ # Test suite for net-proto all platforms. This test suite should be run
5
+ # via the 'rake spec' task.
6
+ ###########################################################################
7
+ require 'net/proto'
8
+ require 'rspec'
9
+
10
+ RSpec.describe Net::Proto do
11
+ # These were the protocols listed in my own /etc/protocols file on Solaris 9
12
+ let(:protocols) do
13
+ %w[
14
+ ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
15
+ xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
16
+ mobile ospf pim ipcomp vrrp sctp hopopt ipv6
17
+ ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
18
+ ]
19
+ end
20
+
21
+ example "version number is set to expected value" do
22
+ expect(Net::Proto::VERSION).to eq('1.4.0')
23
+ expect(Net::Proto::VERSION.frozen?).to eq(true)
24
+ end
25
+
26
+ example "get_protocol method basic functionality" do
27
+ expect(Net::Proto).to respond_to(:get_protocol)
28
+ end
29
+
30
+ example "get_protocol method accepts a string or a number" do
31
+ expect{ Net::Proto.get_protocol(1) }.not_to raise_error
32
+ expect{ Net::Proto.get_protocol('tcp') }.not_to raise_error
33
+ end
34
+
35
+ example "get_protocol returns nil if protocol not found" do
36
+ expect(Net::Proto.get_protocol(9999999)).to be_nil
37
+ end
38
+
39
+ example "get_protocol fails if an invalid type is passed" do
40
+ expect{ Net::Proto.get_protocol([]) }.to raise_error(TypeError)
41
+ end
42
+
43
+ example "getprotobynumber basic functionality" do
44
+ expect(Net::Proto).to respond_to(:getprotobynumber)
45
+ expect{ 0.upto(132){ |n| Net::Proto.getprotobynumber(n) } }.not_to raise_error
46
+ expect(Net::Proto.getprotobynumber(1)).to be_kind_of(String)
47
+ end
48
+
49
+ example "getprotobynumber returns the expected result" do
50
+ expect(Net::Proto.getprotobynumber(1)).to eq('icmp')
51
+ expect(Net::Proto.getprotobynumber(6)).to eq('tcp')
52
+ end
53
+
54
+ example "getprotobynumber returns nil if not found" do
55
+ expect(Net::Proto.getprotobynumber(9999999)).to eq(nil)
56
+ expect(Net::Proto.getprotobynumber(-1)).to eq(nil)
57
+ end
58
+
59
+ example "getprotobynumber raises a TypeError if a non-numeric arg is used" do
60
+ expect{ Net::Proto.getprotobynumber('foo') }.to raise_error(TypeError)
61
+ expect{ Net::Proto.getprotobynumber(nil) }.to raise_error(TypeError)
62
+ end
63
+
64
+ example "getprotobyname method basic functionality" do
65
+ expect(Net::Proto).to respond_to(:getprotobyname)
66
+ protocols.each{ |n| expect{ Net::Proto.getprotobyname(n) }.not_to raise_error }
67
+ end
68
+
69
+ example "getprotobyname returns the expected result" do
70
+ expect(Net::Proto.getprotobyname('icmp')).to eq(1)
71
+ expect(Net::Proto.getprotobyname('tcp')).to eq(6)
72
+ end
73
+
74
+ example "getprotobyname returns nil if the protocol is not found" do
75
+ expect(Net::Proto.getprotobyname('foo')).to be_nil
76
+ expect(Net::Proto.getprotobyname('tcpx')).to be_nil
77
+ expect(Net::Proto.getprotobyname('')).to be_nil
78
+ end
79
+
80
+ example "getprotobyname raises a TypeError if an invalid arg is passed" do
81
+ expect{ Net::Proto.getprotobyname(1) }.to raise_error(TypeError)
82
+ expect{ Net::Proto.getprotobyname(nil) }.to raise_error(TypeError)
83
+ end
84
+
85
+ example "getprotoent basic functionality" do
86
+ expect(Net::Proto).to respond_to(:getprotoent)
87
+ expect{ Net::Proto.getprotoent }.not_to raise_error
88
+ expect(Net::Proto.getprotoent).to be_kind_of(Array)
89
+ end
90
+
91
+ example "getprotoent method returns the expected results" do
92
+ expect(Net::Proto.getprotoent.first).to be_kind_of(Struct::ProtoStruct)
93
+ expect(Net::Proto.getprotoent{}).to be_nil
94
+ end
95
+
96
+ example "struct returned by getprotoent method contains the expected data" do
97
+ protoent = Net::Proto.getprotoent.first
98
+ expect( protoent.members).to eq([:name, :aliases, :proto])
99
+ expect( protoent.name).to be_kind_of(String)
100
+ expect( protoent.aliases).to be_kind_of(Array)
101
+ expect( protoent.proto).to be_kind_of(Integer)
102
+ end
103
+
104
+ example "all members of the aliases struct member are strings" do
105
+ protoent = Net::Proto.getprotoent.first
106
+ expect(protoent.aliases.all?{ |e| e.is_a?(String) }).to eq(true)
107
+ end
108
+
109
+ example "struct returned by getprotoent method is frozen" do
110
+ protoent = Net::Proto.getprotoent.first
111
+ expect(protoent.frozen?).to eq(true)
112
+ end
113
+
114
+ example "there is no constructor" do
115
+ expect{ Net::Proto.new }.to raise_error(NoMethodError)
116
+ end
117
+
118
+ example "ffi functions are private" do
119
+ methods = Net::Proto.methods(false)
120
+ expect(methods.include?(:setprotoent)).to eq(false)
121
+ expect(methods.include?(:endprotoent)).to eq(false)
122
+ end
123
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-proto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -41,30 +41,30 @@ dependencies:
41
41
  name: ffi
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.0'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.0'
54
54
  - !ruby/object:Gem::Dependency
55
- name: test-unit
55
+ name: rspec
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.2'
60
+ version: '3.9'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '2.2'
67
+ version: '3.9'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: rake
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -93,10 +93,10 @@ extra_rdoc_files:
93
93
  - doc/netproto.txt
94
94
  files:
95
95
  - LICENSE
96
- - test
97
- - test/test_net_proto.rb
98
96
  - CHANGES
99
97
  - MANIFEST
98
+ - spec
99
+ - spec/net_proto_spec.rb
100
100
  - README
101
101
  - Rakefile
102
102
  - certs
@@ -149,9 +149,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.0.3
152
+ rubygems_version: 3.1.4
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: A Ruby interface for determining protocol information
156
156
  test_files:
157
- - test/test_net_proto.rb
157
+ - spec/net_proto_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,136 +0,0 @@
1
- ###########################################################################
2
- # test_net_netproto.rb
3
- #
4
- # Test suite for net-proto - all platforms. This test suite should be run
5
- # via the 'rake test' task.
6
- ###########################################################################
7
- require 'net/proto'
8
- require 'test-unit'
9
-
10
- class TC_Net_Proto < Test::Unit::TestCase
11
-
12
- # These were the protocols listed in my own /etc/protocols file on Solaris 9
13
- def self.startup
14
- @@protocols = %w/
15
- ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
16
- xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
17
- mobile ospf pim ipcomp vrrp sctp hopopt ipv6
18
- ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
19
- /
20
- end
21
-
22
- def setup
23
- @protoent = nil
24
- end
25
-
26
- test "version number is set to expected value" do
27
- assert_equal('1.3.1', Net::Proto::VERSION)
28
- assert_true(Net::Proto::VERSION.frozen?)
29
- end
30
-
31
- test "get_protocol method basic functionality" do
32
- assert_respond_to(Net::Proto, :get_protocol)
33
- end
34
-
35
- test "get_protocol method accepts a string or a number" do
36
- assert_nothing_raised{ Net::Proto.get_protocol(1) }
37
- assert_nothing_raised{ Net::Proto.get_protocol('tcp') }
38
- end
39
-
40
- test "get_protocol returns nil if protocol not found" do
41
- assert_nil(Net::Proto.get_protocol(9999999))
42
- end
43
-
44
- test "get_protocol fails if an invalid type is passed" do
45
- assert_raise(TypeError){ Net::Proto.get_protocol([]) }
46
- end
47
-
48
- test "getprotobynumber basic functionality" do
49
- assert_respond_to(Net::Proto, :getprotobynumber)
50
- assert_nothing_raised{ 0.upto(132){ |n| Net::Proto.getprotobynumber(n) } }
51
- assert_kind_of(String, Net::Proto.getprotobynumber(1))
52
- end
53
-
54
- test "getprotobynumber returns the expected result" do
55
- assert_equal('icmp', Net::Proto.getprotobynumber(1))
56
- assert_equal('tcp', Net::Proto.getprotobynumber(6))
57
- end
58
-
59
- test "getprotobynumber returns nil if not found" do
60
- assert_equal(nil, Net::Proto.getprotobynumber(9999999))
61
- assert_equal(nil, Net::Proto.getprotobynumber(-1))
62
- end
63
-
64
- test "getprotobynumber raises a TypeError if a non-numeric arg is used" do
65
- assert_raise(TypeError){ Net::Proto.getprotobynumber('foo') }
66
- assert_raise(TypeError){ Net::Proto.getprotobynumber(nil) }
67
- end
68
-
69
- test "getprotobyname method basic functionality" do
70
- assert_respond_to(Net::Proto, :getprotobyname)
71
- @@protocols.each{ |n| assert_nothing_raised{ Net::Proto.getprotobyname(n) } }
72
- end
73
-
74
- test "getprotobyname returns the expected result" do
75
- assert_equal(1, Net::Proto.getprotobyname('icmp'))
76
- assert_equal(6, Net::Proto.getprotobyname('tcp'))
77
- end
78
-
79
- test "getprotobyname returns nil if the protocol is not found" do
80
- assert_nil(Net::Proto.getprotobyname('foo'))
81
- assert_nil(Net::Proto.getprotobyname('tcpx'))
82
- assert_nil(Net::Proto.getprotobyname(''))
83
- end
84
-
85
- test "getprotobyname raises a TypeError if an invalid arg is passed" do
86
- assert_raises(TypeError){ Net::Proto.getprotobyname(1) }
87
- assert_raises(TypeError){ Net::Proto.getprotobyname(nil) }
88
- end
89
-
90
- test "getprotoent basic functionality" do
91
- assert_respond_to(Net::Proto, :getprotoent)
92
- assert_nothing_raised{ Net::Proto.getprotoent }
93
- assert_kind_of(Array, Net::Proto.getprotoent)
94
- end
95
-
96
- test "getprotoent method returns the expected results" do
97
- assert_kind_of(Struct::ProtoStruct, Net::Proto.getprotoent.first)
98
- assert_nil(Net::Proto.getprotoent{})
99
- end
100
-
101
- test "struct returned by getprotoent method contains the expected data" do
102
- @protoent = Net::Proto.getprotoent.first
103
- assert_equal([:name, :aliases, :proto], @protoent.members)
104
- assert_kind_of(String, @protoent.name)
105
- assert_kind_of(Array, @protoent.aliases)
106
- assert_kind_of(Integer, @protoent.proto)
107
- end
108
-
109
- test "all members of the aliases struct member are strings" do
110
- @protoent = Net::Proto.getprotoent.first
111
- assert_true(@protoent.aliases.all?{ |e| e.is_a?(String) })
112
- end
113
-
114
- test "struct returned by getprotoent method is frozen" do
115
- @protoent = Net::Proto.getprotoent.first
116
- assert_true(@protoent.frozen?)
117
- end
118
-
119
- test "there is no constructor" do
120
- assert_raise(NoMethodError){ Net::Proto.new }
121
- end
122
-
123
- test "ffi functions are private" do
124
- methods = Net::Proto.methods(false).map{ |m| m.to_sym }
125
- assert_false(methods.include?(:setprotoent))
126
- assert_false(methods.include?(:endprotoent))
127
- end
128
-
129
- def teardown
130
- @protoent = nil
131
- end
132
-
133
- def self.shutdown
134
- @@protocols = nil
135
- end
136
- end