Sha256: ac5457820f351ef71b96b86a378eb61e28f873cd594ecc94a9c1dc57f0d17f0b

Contents?: true

Size: 914 Bytes

Versions: 7

Compression:

Stored size: 914 Bytes

Contents

require 'test_helper'

class ServerAdaptersFormattedTest < Test::Unit::TestCase

  def setup
    @definition = [:tld, ".de", "whois.denic.de", {:format => "-T dn,ace -C US-ASCII %s"}]
    @klass  = Whois::Server::Adapters::Formatted
    @server = @klass.new(*@definition)
  end

  def test_query
    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")],
                 answer.parts
  end

  def test_query_should_raise_without_option_format
    @server = @klass.new(*[:tld, ".de", "whois.denic.de", {}])
    @server.expects(:ask_the_socket).never
    assert_raise(Whois::ServerError) { @server.query("domain.foo") }
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
whois-1.2.2 test/whois/server/adapters/formatted_test.rb
whois-1.2.1 test/whois/server/adapters/formatted_test.rb
whois-1.2.0 test/whois/server/adapters/formatted_test.rb
whois-1.1.8 test/server/adapters/formatted_test.rb
whois-1.1.7 test/server/adapters/formatted_test.rb
whois-1.1.6 test/server/adapters/formatted_test.rb
whois-1.1.5 test/server/adapters/formatted_test.rb