Sha256: e98482995bcc8da460b26f816d5fbae138be2ba61d3a5aab61df9197063661ed

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"

describe Whois::Server::Adapters::Afilias do

  before(:each) do
    @definition = [:tld, ".test", "whois.afilias-grs.info", {}]
    @server = klass.new(*@definition)
  end


  describe "#query" do
    context "without referral" do
      it "returns the WHOIS record" do
        response = "No match for DOMAIN.TEST."
        expected = response
        @server.expects(:ask_the_socket).with("domain.test", "whois.afilias-grs.info", 43).returns(response)

        record = @server.query("domain.test")
        record.to_s.should  == expected
        record.parts.should have(1).part
        record.parts.should == [Whois::Record::Part.new(:body => response, :host => "whois.afilias-grs.info")]
      end
    end

    context "with referral" do
      it "follows all referrals" do
        referral = File.read(fixture("referrals/afilias.bz.txt"))
        response = "Match for DOMAIN.TEST."
        expected = referral + "\n" + response
        @server.expects(:ask_the_socket).with("domain.test", "whois.afilias-grs.info", 43).returns(referral)
        @server.expects(:ask_the_socket).with("domain.test", "whois.belizenic.bz", 43).returns(response)

        record = @server.query("domain.test")
        record.to_s.should  == expected
        record.parts.should have(2).parts
        record.parts.should == [Whois::Record::Part.new(:body => referral, :host => "whois.afilias-grs.info"), Whois::Record::Part.new(:body => response, :host => "whois.belizenic.bz")]
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whois-2.6.3 spec/whois/server/adapters/afilias_spec.rb
whois-2.6.2 spec/whois/server/adapters/afilias_spec.rb
whois-2.6.1 spec/whois/server/adapters/afilias_spec.rb
whois-2.6.0 spec/whois/server/adapters/afilias_spec.rb