Sha256: 2e2175eb855905159f72d0c62a8858fbf9f3bb2f066ba54311d66e07b917269c

Contents?: true

Size: 963 Bytes

Versions: 21

Compression:

Stored size: 963 Bytes

Contents

require 'test_helper'

class ServerAdaptersStandardTest < Test::Unit::TestCase

  def setup
    @definition = [:tld, ".foo", "whois.foo", {}]
    @klass  = Whois::Server::Adapters::Standard
    @server = @klass.new(*@definition)
  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
    assert_equal [Whois::Answer::Part.new(response, "whois.foo")],
                 @server.buffer
  end

  def test_query_with_port
    @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
    assert_equal [Whois::Answer::Part.new(response, "whois.foo")],
                 @server.buffer
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
whois-0.8.0 test/server/adapters/standard_test.rb