Sha256: 54b99f4094c432cd1c8b652449c7c104015803b57fa68243b61f2273b373fee2

Contents?: true

Size: 1.44 KB

Versions: 14

Compression:

Stored size: 1.44 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

14 entries across 14 versions & 1 rubygems

Version Path
whois-2.5.1 spec/whois/record/nameserver_spec.rb
whois-2.5.0 spec/whois/record/nameserver_spec.rb
whois-2.4.0 spec/whois/record/nameserver_spec.rb
whois-2.3.0 spec/whois/record/nameserver_spec.rb
whois-2.2.0 spec/whois/record/nameserver_spec.rb
whois-2.1.0 spec/whois/record/nameserver_spec.rb
whois-2.0.7 spec/whois/record/nameserver_spec.rb
whois-2.0.6 spec/whois/record/nameserver_spec.rb
whois-2.0.5 spec/whois/record/nameserver_spec.rb
whois-2.0.4 spec/whois/record/nameserver_spec.rb
whois-2.0.3 spec/whois/record/nameserver_spec.rb
whois-2.0.2 spec/whois/record/nameserver_spec.rb
whois-2.0.1 spec/whois/record/nameserver_spec.rb
whois-2.0.0 spec/whois/record/nameserver_spec.rb