Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bad ping after good should unset duration? #5

Closed
wants to merge 2 commits into from

2 participants

@tardate

In 1.4.1, it seems a bad ping after a good ping will leave @duration set at the result of the good ping.

I'd expect it to unset @duration .. these two commits include tests (I've just added for external and LDAP classes so far) and a fix for this behaviour so that a bad ping will cause duration to be unset.

NB: Daniel, note that the base commit for this patch is my prior pull request.

tardate added some commits
@tardate tardate bad ping after good should unset duration
* in 1.4.1, a bad ping after a good ping will leave @duration set at the result of the good ping. I'd expect it to unset @duration .. this commit includes a test and a fix for this behaviour
4c18e5b
@tardate tardate Add Ping::LDAP test for bad ping after good 965031c
@djberg96
Owner

Merged and released. Thanks!

@djberg96 djberg96 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2011
  1. @tardate

    bad ping after good should unset duration

    tardate authored
    * in 1.4.1, a bad ping after a good ping will leave @duration set at the result of the good ping. I'd expect it to unset @duration .. this commit includes a test and a fix for this behaviour
  2. @tardate
This page is out of date. Refresh to see the latest.
View
1  lib/net/ping/ping.rb
@@ -80,6 +80,7 @@ def ping(host = @host)
raise ArgumentError, 'no host specified' unless host
@exception = nil
@warning = nil
+ @duration = nil
end
alias ping? ping
View
7 test/test_net_ping_external.rb
@@ -59,6 +59,13 @@ def setup
assert_kind_of(Float, @pe.duration)
end
+ test "duration is unset if a bad ping follows a good ping" do
+ assert_nothing_raised{ @pe.ping }
+ assert_not_nil(@pe.duration)
+ assert_false(@pe.ping?(@bogus))
+ assert_nil(@pe.duration)
+ end
+
test "host getter basic functionality" do
assert_respond_to(@pe, :host)
assert_equal('www.ruby-lang.org', @pe.host)
View
10 test/test_net_ping_ldap.rb
@@ -33,7 +33,8 @@ def setup
@ldap = Net::Ping::LDAP.new(@@uri, @@timeout)
@ldap.username = @@cn
@ldap.password = @@password
- @bad = Net::Ping::LDAP.new('ldap://blabfoobarurghxxxx.com') # One hopes not
+ @bogus = 'ldap://blabfoobarurghxxxx.com' # One hopes so
+ @bad = Net::Ping::LDAP.new(@bogus)
end
def teardown
@@ -81,6 +82,13 @@ def teardown
assert_nil(@ldap.duration)
end
+ test "duration is unset if a bad ping follows a good ping" do
+ assert_true{ @ldap.ping }
+ assert_not_nil(@ldap.duration)
+ assert_false(@ldap.ping?(@bogus))
+ assert_nil(@ldap.duration)
+ end
+
test 'host attribute basic functionality' do
assert_respond_to(@ldap, :host)
assert_respond_to(@ldap, :host=)
Something went wrong with that request. Please try again.