Sha256: 8be1f3cef3d8d68685d3d9b1ad397d95b58c06be701329945f900726e28254c1
Contents?: true
Size: 1.92 KB
Versions: 8
Compression:
Stored size: 1.92 KB
Contents
require "spec_helper" describe Whois::Server::Adapters::Formatted do before(:each) do @definition = [:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" }] end describe "#query" do it "returns the WHOIS record" do response = "Whois Response" expected = response server = klass.new(*@definition) server.expects(:ask_the_socket).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 43, Whois::Server::Adapters::Base::DEFAULT_BIND_HOST, nil).returns(response) record = server.query("domain.de") record.to_s.should == expected record.parts.should == [Whois::Record::Part.new(response, "whois.denic.de")] end context "without format option" do it "raises an error" do lambda do server = klass.new(*[:tld, ".de", "whois.denic.de", {}]) server.expects(:ask_the_socket).never server.query("domain.de") end.should raise_error(Whois::ServerError) end end context "with port option" do it "sends the request to given port" do response = "Whois Response" server = klass.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s", :port => 20 }) server.expects(:ask_the_socket).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 20, Whois::Server::Adapters::Base::DEFAULT_BIND_HOST, nil).returns(response) server.query("domain.de") end end context "with bind option" do it "binds the request to given host and port" do response = "Whois Response" server = klass.new(:tld, ".de", "whois.denic.de", { :format => "-T dn,ace -C US-ASCII %s" }) server.configure(:bind_host => "192.168.0.100", :bind_port => 3000) server.expects(:ask_the_socket).with("-T dn,ace -C US-ASCII domain.de", "whois.denic.de", 43, "192.168.0.100", 3000).returns(response) server.query("domain.de") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems