Permalink
Newer
Older
100644 59 lines (47 sloc) 1.85 KB
1
require "spec_helper"
2
3
describe Whois do
4
5
let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
6
7
describe "Basic WHOIS querying and parsing" do
8
it "works" do
9
with_definitions do
10
Whois::Server.define(:tld, ".it", "whois.nic.it")
11
Whois::Server::Adapters::Standard.any_instance \
12
.expects(:ask_the_socket) \
13
.with("example.it", "whois.nic.it", 43) \
14
.returns(response)
16
record = Whois.query("example.it")
18
record.should be_a(Whois::Record)
19
record.should be_available
20
record.should_not be_registered
22
record.parser.should be_a(Whois::Record::Parser)
23
record.parser.parsers.first.should be_a(Whois::Record::Parser::WhoisNicIt)
28
describe "Passing :bind_host and :bind_port options" do
29
it "binds the WHOIS query to given host and port" do
30
with_definitions do
31
Whois::Server.define(:tld, ".it", "whois.nic.it")
32
Whois::Server::Adapters::Standard.any_instance \
33
.expects(:ask_the_socket) \
34
.with("example.it", "whois.nic.it", 43, "192.168.1.1", 3000) \
35
.returns(response)
36
37
client = Whois::Client.new(:bind_host => "192.168.1.1", :bind_port => 3000)
38
client.query("example.it")
39
end
40
end
41
end
42
43
describe "Passing :bind_port options" do
44
it "binds the WHOIS query to given port and defaults host" do
45
with_definitions do
46
Whois::Server.define(:tld, ".it", "whois.nic.it")
47
Whois::Server::Adapters::Standard.any_instance \
48
.expects(:ask_the_socket) \
49
.with("example.it", "whois.nic.it", 43, Whois::Server::Adapters::Base::DEFAULT_BIND_HOST, 3000) \
50
.returns(response)
52
client = Whois::Client.new(:bind_port => 3000)
53
client.query("example.it")
54
end
55
end
56
end
57
58
end