Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (47 sloc) 1.892 kb
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
1 require "spec_helper"
2
3 describe Whois do
4
f64800b Simone Carletti Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasionall...
authored
5 let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
6
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
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")
f64800b Simone Carletti Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasionall...
authored
11 Whois::Server::Adapters::Standard.any_instance \
12 .expects(:ask_the_socket) \
13 .with("example.it", "whois.nic.it", 43) \
14 .returns(response)
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
15
5ebb50f Simone Carletti When a :bind_host or :bind_port are supplied, the TCPSocket is binded to...
authored
16 record = Whois.query("example.it")
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
17
e94d872 Simone Carletti Rename Whois::Answer to Whois::Record
authored
18 record.should be_a(Whois::Record)
5ebb50f Simone Carletti When a :bind_host or :bind_port are supplied, the TCPSocket is binded to...
authored
19 record.should be_available
20 record.should_not be_registered
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
21
e94d872 Simone Carletti Rename Whois::Answer to Whois::Record
authored
22 record.parser.should be_a(Whois::Record::Parser)
23 record.parser.parsers.first.should be_a(Whois::Record::Parser::WhoisNicIt)
5ebb50f Simone Carletti When a :bind_host or :bind_port are supplied, the TCPSocket is binded to...
authored
24 end
25 end
26 end
27
f64800b Simone Carletti Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasionall...
authored
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
5ebb50f Simone Carletti When a :bind_host or :bind_port are supplied, the TCPSocket is binded to...
authored
45 with_definitions do
46 Whois::Server.define(:tld, ".it", "whois.nic.it")
f64800b Simone Carletti Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasionall...
authored
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)
5ebb50f Simone Carletti When a :bind_host or :bind_port are supplied, the TCPSocket is binded to...
authored
51
f64800b Simone Carletti Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasionall...
authored
52 client = Whois::Client.new(:bind_port => 3000)
53 client.query("example.it")
54c5dad Simone Carletti Convert Test::Unit to RSpec
authored
54 end
55 end
56 end
57
58 end
Something went wrong with that request. Please try again.