net-ping 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +11 -0
- data/README +4 -6
- data/Rakefile +11 -24
- data/doc/ping.txt +1 -3
- data/lib/net/ping.rb +4 -2
- data/lib/net/ping/external.rb +106 -99
- data/lib/net/ping/http.rb +74 -71
- data/lib/net/ping/ping.rb +3 -3
- data/lib/net/ping/tcp.rb +66 -66
- data/lib/net/ping/udp.rb +94 -94
- data/net-ping.gemspec +28 -26
- data/test/test_net_ping.rb +11 -3
- data/test/test_net_ping_external.rb +63 -68
- data/test/test_net_ping_http.rb +103 -74
- data/test/test_net_ping_icmp.rb +0 -4
- data/test/test_net_ping_tcp.rb +79 -83
- data/test/test_net_ping_udp.rb +108 -88
- data/test/test_net_ping_wmi.rb +0 -4
- metadata +22 -11
data/test/test_net_ping_udp.rb
CHANGED
@@ -1,102 +1,122 @@
|
|
1
|
-
|
1
|
+
########################################################################
|
2
2
|
# test_net_ping_udp.rb
|
3
3
|
#
|
4
|
-
# Test case for the Net::Ping::UDP class. This should be run
|
5
|
-
#
|
4
|
+
# Test case for the Net::Ping::UDP class. This should be run via the
|
5
|
+
# 'test' or 'test:udp' Rake tasks.
|
6
6
|
#
|
7
7
|
# If someone could provide me a host where a udp ping actually
|
8
8
|
# works (with a service check), I would appreciate it. :)
|
9
|
-
|
9
|
+
########################################################################
|
10
10
|
require 'rubygems'
|
11
11
|
gem 'test-unit'
|
12
12
|
|
13
13
|
require 'test/unit'
|
14
14
|
require 'net/ping/udp'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
|
51
|
-
end
|
15
|
+
|
16
|
+
class TC_Net_Ping_UDP < Test::Unit::TestCase
|
17
|
+
def setup
|
18
|
+
Net::Ping::UDP.service_check = false
|
19
|
+
@host = '127.0.0.1'
|
20
|
+
@udp = Net::Ping::UDP.new(@host)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "ping basic functionality" do
|
24
|
+
assert_respond_to(@udp, :ping)
|
25
|
+
assert_nothing_raised{ @udp.ping }
|
26
|
+
end
|
27
|
+
|
28
|
+
test "ping accepts a host as an argument" do
|
29
|
+
assert_nothing_raised{ @udp.ping(@host) }
|
30
|
+
end
|
31
|
+
|
32
|
+
test "ping? is an alias for ping" do
|
33
|
+
assert_respond_to(@udp, :ping?)
|
34
|
+
assert_alias_method(@udp, :ping?, :ping)
|
35
|
+
end
|
36
|
+
|
37
|
+
test "pingecho is an alias for ping" do
|
38
|
+
assert_respond_to(@udp, :pingecho)
|
39
|
+
assert_alias_method(@udp, :pingecho, :ping)
|
40
|
+
end
|
41
|
+
|
42
|
+
test "a successful udp ping returns true" do
|
43
|
+
assert_true(@udp.ping?)
|
44
|
+
end
|
45
|
+
|
46
|
+
test "bind basic functionality" do
|
47
|
+
assert_respond_to(@udp, :bind)
|
48
|
+
assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
51
|
+
test "duration basic functionality" do
|
52
|
+
assert_nothing_raised{ @udp.ping }
|
53
|
+
assert_respond_to(@udp, :duration)
|
54
|
+
assert_kind_of(Float, @udp.duration)
|
55
|
+
end
|
56
|
+
|
57
|
+
test "host basic functionality" do
|
58
|
+
assert_respond_to(@udp, :host)
|
59
|
+
assert_respond_to(@udp, :host=)
|
60
|
+
assert_equal('127.0.0.1', @udp.host)
|
61
|
+
end
|
62
|
+
|
63
|
+
test "port basic functionality" do
|
64
|
+
assert_respond_to(@udp, :port)
|
65
|
+
assert_respond_to(@udp, :port=)
|
66
|
+
assert_equal(7, @udp.port)
|
67
|
+
end
|
68
|
+
|
69
|
+
test "timeout basic functionality" do
|
70
|
+
assert_respond_to(@udp, :timeout)
|
71
|
+
assert_respond_to(@udp, :timeout=)
|
72
|
+
end
|
73
|
+
|
74
|
+
test "timeout default value is five" do
|
75
|
+
assert_equal(5, @udp.timeout)
|
76
|
+
end
|
77
|
+
|
78
|
+
test "exception basic functionality" do
|
79
|
+
assert_respond_to(@udp, :exception)
|
80
|
+
end
|
81
|
+
|
82
|
+
test "the exception attribute returns nil if the ping is successful" do
|
83
|
+
assert_true(@udp.ping?)
|
84
|
+
assert_nil(@udp.exception)
|
85
|
+
end
|
86
|
+
|
87
|
+
test "the exception attribute is not nil if the ping is unsuccessful" do
|
88
|
+
assert_false(@udp.ping?('www.ruby-lang.org'))
|
89
|
+
assert_not_nil(@udp.exception)
|
90
|
+
end
|
91
|
+
|
92
|
+
test "warning basic functionality" do
|
93
|
+
assert_respond_to(@udp, :warning)
|
94
|
+
end
|
95
|
+
|
96
|
+
test "the warning attribute returns nil if the ping is successful" do
|
97
|
+
assert_true(@udp.ping?)
|
98
|
+
assert_nil(@udp.warning)
|
99
|
+
end
|
86
100
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
101
|
+
test "service_check basic functionality" do
|
102
|
+
assert_respond_to(Net::Ping::UDP, :service_check)
|
103
|
+
assert_respond_to(Net::Ping::UDP, :service_check=)
|
104
|
+
end
|
105
|
+
|
106
|
+
test "service_check attribute has been set to false" do
|
107
|
+
assert_false(Net::Ping::UDP.service_check)
|
108
|
+
end
|
92
109
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
110
|
+
test "service_check getter method does not accept arguments" do
|
111
|
+
assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
|
112
|
+
end
|
113
|
+
|
114
|
+
test "service_check setter method only accepts boolean arguments" do
|
115
|
+
assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
|
116
|
+
end
|
117
|
+
|
118
|
+
def teardown
|
119
|
+
@host = nil
|
120
|
+
@udp = nil
|
121
|
+
end
|
102
122
|
end
|
data/test/test_net_ping_wmi.rb
CHANGED
@@ -22,10 +22,6 @@ class TC_Ping_WMI < Test::Unit::TestCase
|
|
22
22
|
@wmi = Ping::WMI.new(@host) if @@windows
|
23
23
|
end
|
24
24
|
|
25
|
-
def test_version
|
26
|
-
assert_equal('1.3.2', Ping::WMI::VERSION)
|
27
|
-
end
|
28
|
-
|
29
25
|
def test_ping_basic
|
30
26
|
omit_unless(@@windows, 'skipped on Unix platforms')
|
31
27
|
assert_respond_to(@wmi, :ping)
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 3
|
8
|
+
- 3
|
9
|
+
version: 1.3.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Daniel J. Berger
|
@@ -9,20 +14,24 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-06-21 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: test-unit
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
30
|
+
- 9
|
31
|
+
version: 2.0.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
description: " The net-ping library provides a ping interface for Ruby. It includes\n separate TCP, HTTP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
|
26
35
|
email: djberg96@gmail.com
|
27
36
|
executables: []
|
28
37
|
|
@@ -71,18 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
80
|
requirements:
|
72
81
|
- - ">="
|
73
82
|
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
74
85
|
version: "0"
|
75
|
-
version:
|
76
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
87
|
requirements:
|
78
88
|
- - ">="
|
79
89
|
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
80
92
|
version: "0"
|
81
|
-
version:
|
82
93
|
requirements: []
|
83
94
|
|
84
95
|
rubyforge_project: shards
|
85
|
-
rubygems_version: 1.3.
|
96
|
+
rubygems_version: 1.3.6
|
86
97
|
signing_key:
|
87
98
|
specification_version: 3
|
88
99
|
summary: A ping interface for Ruby.
|