Sha256: 80c9d485fbbbab95c5efd4aa041a6c2cf6c3bafbada7dce4fd274999eb80c891

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require "spec_helper"

describe Whois::Record::Nameserver do

  it "inherits from SuperStruct" do
    klass.ancestors.should include(SuperStruct)
  end


  describe "#initialize" do
    it "accepts an empty value" do
      lambda do
        i = klass.new
        i.name.should be_nil
      end.should_not raise_error
    end

    it "accepts an empty hash" do
      lambda do
        i = klass.new({})
        i.name.should be_nil
      end.should_not raise_error
    end

    # it "initializes a new instance from given params" do
    #   i = klass.new("ns1.example.com", "127.0.0.1")

    #   i.name.should == "ns1.example.com"
    #   i.ipv4.should == "127.0.0.1"
    #   i.ipv6.should be_nil
    # end

    it "initializes a new instance from given hash" do
      i = klass.new(:name => "ns1.example.com", :ipv4 => "127.0.0.1")

      i.name.should == "ns1.example.com"
      i.ipv4.should == "127.0.0.1"
      i.ipv6.should be_nil
    end

    it "initializes a new instance from given block" do
      i = klass.new do |c|
        c.name  = "ns1.example.com"
        c.ipv4  = "127.0.0.1"
      end

      i.name.should == "ns1.example.com"
      i.ipv4.should == "127.0.0.1"
      i.ipv6.should be_nil
    end
  end

  describe "#to_s" do
    it "returns the string representation of this object" do
      klass.new(:name => "ns1.example.com").to_s.should == "ns1.example.com"
      klass.new(:name => nil).to_s.should == ""
      klass.new.to_s.should == ""
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whois-2.6.3 spec/whois/record/nameserver_spec.rb
whois-2.6.2 spec/whois/record/nameserver_spec.rb
whois-2.6.1 spec/whois/record/nameserver_spec.rb
whois-2.6.0 spec/whois/record/nameserver_spec.rb