net-ping 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.3.6 - 4-Sep-2010
2
+ * Fixed variable naming issue in Net::Ping::External. Thanks go to taw
3
+ for the spot.
4
+ * Added a default Rake task.
5
+ * Refactored the tests for Net::Ping::External to take advantage of the
6
+ features of test-unit 2.x.
7
+
1
8
  == 1.3.5 - 3-Sep-2010
2
9
  * Allow for custom user agent in Net::Ping::HTTP. Thanks go to Michael
3
10
  Reinsch for the patch.
data/Rakefile CHANGED
@@ -82,3 +82,5 @@ namespace 'test' do
82
82
  t.test_files = FileList['test/test_net_ping_wmi.rb']
83
83
  end
84
84
  end
85
+
86
+ task :default => :test
@@ -35,7 +35,7 @@ module Net
35
35
  def ping(host = @host)
36
36
  super(host)
37
37
 
38
- input, output, error = ""
38
+ stdin, stdout, stderr = ""
39
39
  pstring = "ping "
40
40
  bool = false
41
41
  orig_cp = nil
@@ -63,12 +63,12 @@ module Net
63
63
  err = nil
64
64
 
65
65
  Timeout.timeout(@timeout){
66
- input, output, error = Open3.popen3(pstring)
67
- err = error.gets # Can't chomp yet, might be nil
66
+ stdin, stdout, stderr = Open3.popen3(pstring)
67
+ err = stderr.gets # Can't chomp yet, might be nil
68
68
  }
69
69
 
70
- input.close
71
- error.close
70
+ stdin.close
71
+ stderr.close
72
72
 
73
73
  if CWINDOWS && GetConsoleCP() != orig_cp
74
74
  SetConsoleCP(orig_cp)
@@ -83,8 +83,8 @@ module Net
83
83
  end
84
84
  # The "no answer" response goes to stdout, not stderr, so check it
85
85
  else
86
- lines = output.readlines
87
- output.close
86
+ lines = stdout.readlines
87
+ stdout.close
88
88
  if lines.nil? || lines.empty?
89
89
  bool = true
90
90
  else
@@ -109,9 +109,9 @@ module Net
109
109
  rescue Exception => error
110
110
  @exception = error.message
111
111
  ensure
112
- input.close if input && !input.closed?
113
- error.close if error && !error.closed?
114
- output.close if output && !output.closed?
112
+ stdin.close if stdin && !stdin.closed?
113
+ stdout.close if stdout && !stdout.closed?
114
+ stderr.close if stderr && !stderr.closed?
115
115
  end
116
116
 
117
117
  # There is no duration if the ping failed
@@ -10,7 +10,7 @@ module Net
10
10
  #
11
11
  class Ping
12
12
  # The version of the net-ping library.
13
- VERSION = '1.3.5'
13
+ VERSION = '1.3.6'
14
14
 
15
15
  # The host to ping. In the case of Ping::HTTP, this is the URI.
16
16
  attr_accessor :host
@@ -3,7 +3,7 @@ require 'rbconfig'
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'net-ping'
6
- gem.version = '1.3.5'
6
+ gem.version = '1.3.6'
7
7
  gem.license = 'Artistic 2.0'
8
8
  gem.author = 'Daniel J. Berger'
9
9
  gem.email = 'djberg96@gmail.com'
@@ -21,6 +21,6 @@ end
21
21
 
22
22
  class TC_Net_Ping < Test::Unit::TestCase
23
23
  def test_net_ping_version
24
- assert_equal('1.3.5', Net::Ping::VERSION)
24
+ assert_equal('1.3.6', Net::Ping::VERSION)
25
25
  end
26
26
  end
@@ -18,64 +18,98 @@ class TC_Net_Ping_External < Test::Unit::TestCase
18
18
  @bad = Net::Ping::External.new(@bogus)
19
19
  end
20
20
 
21
- def test_ping
21
+ test "ping basic functionality" do
22
22
  assert_respond_to(@pe, :ping)
23
+ end
24
+
25
+ test "ping with no arguments" do
23
26
  assert_nothing_raised{ @pe.ping }
27
+ end
28
+
29
+ test "ping accepts a hostname" do
24
30
  assert_nothing_raised{ @pe.ping(@host) }
25
31
  end
26
32
 
27
- def test_ping_aliases
33
+ test "ping returns a boolean" do
34
+ assert_boolean(@pe.ping)
35
+ assert_boolean(@bad.ping)
36
+ end
37
+
38
+ test "ping? alias" do
28
39
  assert_respond_to(@pe, :ping?)
29
- assert_respond_to(@pe, :pingecho)
30
- assert_nothing_raised{ @pe.ping? }
31
- assert_nothing_raised{ @pe.ping?(@host) }
40
+ assert_alias_method(@pe, :ping?, :ping)
41
+ end
42
+
43
+ test "pingecho alias" do
32
44
  assert_nothing_raised{ @pe.pingecho }
33
- assert_nothing_raised{ @pe.pingecho(@host) }
45
+ assert_alias_method(@pe, :pingecho, :ping)
34
46
  end
35
47
 
36
- def test_good_ping
37
- assert_equal(true, @pe.ping?)
48
+ test "pinging a good host returns true" do
49
+ assert_true(@pe.ping?)
38
50
  end
39
51
 
40
- def test_bad_ping
41
- assert_equal(false, @bad.ping?)
42
- assert_equal(false, @bad.exception.nil?, "Bad exception data")
52
+ test "pinging a bogus host returns false" do
53
+ assert_false(@bad.ping?)
43
54
  end
44
55
 
45
- def test_duration
56
+ test "duration basic functionality" do
46
57
  assert_nothing_raised{ @pe.ping }
47
58
  assert_respond_to(@pe, :duration)
48
59
  assert_kind_of(Float, @pe.duration)
49
60
  end
50
61
 
51
- def test_host
62
+ test "host getter basic functionality" do
52
63
  assert_respond_to(@pe, :host)
53
- assert_respond_to(@pe, :host=)
54
64
  assert_equal('www.ruby-lang.org', @pe.host)
55
65
  end
56
66
 
57
- def test_port
67
+ test "host setter basic functionality" do
68
+ assert_respond_to(@pe, :host=)
69
+ assert_nothing_raised{ @pe.host = @bad }
70
+ assert_equal(@bad, @pe.host)
71
+ end
72
+
73
+ test "port getter basic functionality" do
58
74
  assert_respond_to(@pe, :port)
59
- assert_respond_to(@pe, :port=)
60
75
  assert_equal(7, @pe.port)
61
76
  end
62
77
 
63
- def test_timeout
78
+ test "port setter basic functionality" do
79
+ assert_respond_to(@pe, :port=)
80
+ assert_nothing_raised{ @pe.port = 90 }
81
+ assert_equal(90, @pe.port)
82
+ end
83
+
84
+ test "timeout getter basic functionality" do
64
85
  assert_respond_to(@pe, :timeout)
65
- assert_respond_to(@pe, :timeout=)
66
86
  assert_equal(5, @pe.timeout)
67
87
  end
68
88
 
69
- def test_exception
89
+ test "timeout setter basic functionality" do
90
+ assert_respond_to(@pe, :timeout=)
91
+ assert_nothing_raised{ @pe.timeout = 30 }
92
+ assert_equal(30, @pe.timeout)
93
+ end
94
+
95
+ test "exception method basic functionality" do
70
96
  assert_respond_to(@pe, :exception)
71
- assert_nothing_raised{ @pe.ping }
72
- assert_nothing_raised{ @bad.ping }
73
97
  assert_nil(@pe.exception)
98
+ end
99
+
100
+ test "pinging a bogus host stores exception data" do
101
+ assert_nothing_raised{ @bad.ping? }
74
102
  assert_not_nil(@bad.exception)
75
103
  end
76
104
 
77
- def test_warning
105
+ test "pinging a good host results in no exception data" do
106
+ assert_nothing_raised{ @pe.ping }
107
+ assert_nil(@pe.exception)
108
+ end
109
+
110
+ test "warning basic functionality" do
78
111
  assert_respond_to(@pe, :warning)
112
+ assert_nil(@pe.warning)
79
113
  end
80
114
 
81
115
  def teardown
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 5
9
- version: 1.3.5
8
+ - 6
9
+ version: 1.3.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel J. Berger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-03 00:00:00 -06:00
17
+ date: 2010-09-05 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency