Permalink
Browse files

Cleanup Whois::Adapter::Base @buffer after a successful request.

  • Loading branch information...
1 parent 6f306d7 commit 4a4179bf12df52310bcf9e5bd6c60410b14e00b1 @weppos committed May 16, 2010
View
2 CHANGELOG.rdoc
@@ -7,6 +7,8 @@
* FIXED: Occasionally the library raises a "superclass mismatch for class DateTime (TypeError)" error.
+* CHANGED: Cleanup Whois::Adapter::Base @buffer after a successful request.
+
== Release 1.1.4
View
4 Manifest
@@ -56,6 +56,7 @@ lib/whois/answer/parser/whois.isnic.is.rb
lib/whois/answer/parser/whois.jprs.jp.rb
lib/whois/answer/parser/whois.meregistry.net.rb
lib/whois/answer/parser/whois.museum.rb
+lib/whois/answer/parser/whois.net.ua.rb
lib/whois/answer/parser/whois.nic-se.se.rb
lib/whois/answer/parser/whois.nic.ac.rb
lib/whois/answer/parser/whois.nic.af.rb
@@ -163,6 +164,7 @@ test/answer/parser/whois.isnic.is_test.rb
test/answer/parser/whois.jprs.jp_test.rb
test/answer/parser/whois.meregistry.net_test.rb
test/answer/parser/whois.museum_test.rb
+test/answer/parser/whois.net.ua_test.rb
test/answer/parser/whois.nic-se.se_test.rb
test/answer/parser/whois.nic.ac_test.rb
test/answer/parser/whois.nic.af_test.rb
@@ -331,6 +333,8 @@ test/testcases/responses/whois.meregistry.net/available.txt
test/testcases/responses/whois.meregistry.net/registered.txt
test/testcases/responses/whois.museum/available.txt
test/testcases/responses/whois.museum/registered.txt
+test/testcases/responses/whois.net.ua/available.txt
+test/testcases/responses/whois.net.ua/registered.txt
test/testcases/responses/whois.nic-se.se/available.txt
test/testcases/responses/whois.nic-se.se/property_nameservers_with_ip.txt
test/testcases/responses/whois.nic-se.se/registered.txt
View
4 lib/whois/server/adapters/base.rb
@@ -65,8 +65,8 @@ def request(qstring)
def with_buffer(&block)
@buffer = []
result = yield(@buffer)
- # @buffer = []
- # result
+ @buffer = []
+ result
end
# Store an answer part in <tt>@buffer</tt>.
View
14 test/server/adapters/afilias_test.rb
@@ -12,10 +12,12 @@ def test_query
response = "No match for DOMAIN.FOO."
expected = response
@server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(response)
- assert_equal expected,
- @server.query("domain.foo").to_s
+ answer = @server.query("domain.foo")
+
+ assert_equal response,
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.afilias-grs.info")],
- @server.buffer
+ answer.parts
end
def test_query_with_referral
@@ -24,10 +26,12 @@ def test_query_with_referral
expected = referral + "\n" + response
@server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(referral)
@server.expects(:ask_the_socket).with("domain.foo", "whois.belizenic.bz", 43).returns(response)
+ answer = @server.query("domain.foo")
+
assert_equal expected,
- @server.query("domain.foo").to_s
+ answer.to_s
assert_equal [Whois::Answer::Part.new(referral, "whois.afilias-grs.info"), Whois::Answer::Part.new(response, "whois.belizenic.bz")],
- @server.buffer
+ answer.parts
end
end
View
13 test/server/adapters/formatted_test.rb
@@ -9,12 +9,15 @@ def setup
end
def test_query
- @server.expects(:ask_the_socket).with("-T dn,ace -C US-ASCII domain.foo", "whois.denic.de", 43).returns("Whois Response")
- response = @server.query("domain.foo")
- assert_equal "Whois Response",
- response.to_s
+ response = "Whois Response"
+ expected = response
+ @server.expects(:ask_the_socket).with("-T dn,ace -C US-ASCII domain.foo", "whois.denic.de", 43).returns(response)
+ answer = @server.query("domain.foo")
+
+ assert_equal expected,
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.denic.de")],
- @server.buffer
+ answer.parts
end
def test_query_should_raise_without_option_format
View
12 test/server/adapters/pir_test.rb
@@ -12,10 +12,12 @@ def test_query
response = "No match for DOMAIN.FOO."
expected = response
@server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(response)
+ answer = @server.query("domain.foo")
+
assert_equal expected,
- @server.query("domain.foo").to_s
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.publicinterestregistry.net")],
- @server.buffer
+ answer.parts
end
def test_query_with_referral
@@ -24,10 +26,12 @@ def test_query_with_referral
expected = referral + "\n" + response
@server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(referral)
@server.expects(:ask_the_socket).with("domain.foo", "whois.iana.org", 43).returns(response)
+ answer = @server.query("domain.foo")
+
assert_equal expected,
- @server.query("domain.foo").to_s
+ answer.to_s
assert_equal [Whois::Answer::Part.new(referral, "whois.publicinterestregistry.net"), Whois::Answer::Part.new(response, "whois.iana.org")],
- @server.buffer
+ answer.parts
end
end
View
25 test/server/adapters/standard_test.rb
@@ -9,21 +9,28 @@ def setup
end
def test_query
- @server.expects(:ask_the_socket).with("domain.foo", "whois.foo", 43).returns("Whois Response")
- response = @server.query("domain.foo")
- assert_equal "Whois Response", response.to_s
+ response = "Whois Response"
+ expected = response
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.foo", 43).returns(response)
+ answer = @server.query("domain.foo")
+
+ assert_equal expected,
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.foo")],
- @server.buffer
+ answer.parts
end
def test_query_with_port
+ response = "Whois Response"
+ expected = response
@server = @klass.new(:tld, ".foo", "whois.foo", { :port => 20 })
- @server.expects(:ask_the_socket).with("domain.foo", "whois.foo", 20).returns("Whois Response")
- response = @server.query("domain.foo")
- assert_equal "Whois Response",
- response.to_s
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.foo", 20).returns(response)
+ answer = @server.query("domain.foo")
+
+ assert_equal expected,
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.foo")],
- @server.buffer
+ answer.parts
end
end
View
12 test/server/adapters/verisign_test.rb
@@ -12,10 +12,12 @@ def test_query
response = "No match for DOMAIN.FOO."
expected = response
@server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(response)
+ answer = @server.query("domain.foo")
+
assert_equal expected,
- @server.query("domain.foo").to_s
+ answer.to_s
assert_equal [Whois::Answer::Part.new(response, "whois.foo")],
- @server.buffer
+ answer.parts
end
def test_query_with_referral
@@ -24,10 +26,12 @@ def test_query_with_referral
expected = referral + "\n" + response
@server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(referral)
@server.expects(:ask_the_socket).with("domain.foo", "whois.markmonitor.com", 43).returns(response)
+ answer = @server.query("domain.foo")
+
assert_equal expected,
- @server.query("domain.foo").to_s
+ answer.to_s
assert_equal [Whois::Answer::Part.new(referral, "whois.foo"), Whois::Answer::Part.new(response, "whois.markmonitor.com")],
- @server.buffer
+ answer.parts
end
def test_query_with_referral_should_extract_the_closest_referral_server_with_more_servers

0 comments on commit 4a4179b

Please sign in to comment.