Sha256: 57287b155447b348c777ffc21c12aa8848945e8146bddaa2067b3816ea317eb4

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe Whois::Record::Contact 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.id.should be_nil
      end.should_not raise_error
    end

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

    it "initializes a new instance from given params" do
      i = klass.new(10, klass::TYPE_REGISTRANT, "John Doe", nil)

      i.id.should == 10
      i.type.should == klass::TYPE_REGISTRANT
      i.name.should == "John Doe"
      i.organization.should be_nil
    end

    it "initializes a new instance from given hash" do
      i = klass.new(:id => 10, :name => "John Doe", :type => klass::TYPE_REGISTRANT)

      i.id.should == 10
      i.type.should == klass::TYPE_REGISTRANT
      i.name.should == "John Doe"
      i.organization.should be_nil
    end

    it "initializes a new instance from given block" do
      i = klass.new do |c|
        c.id    = 10
        c.type  = klass::TYPE_REGISTRANT
        c.name  = "John Doe"
      end

      i.id.should == 10
      i.type.should == klass::TYPE_REGISTRANT
      i.name.should == "John Doe"
      i.organization.should be_nil
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

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