PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/spec/whois/record/nameserver_spec.rb

http://github.com/weppos/whois
Ruby | 63 lines | 43 code | 14 blank | 6 comment | 7 complexity | a1c11a37d398f95c5ade8ec20d213610 MD5 | raw file
Possible License(s): MIT
  1. require 'spec_helper'
  2. require 'whois/record/nameserver'
  3. describe Whois::Record::Nameserver do
  4. it "inherits from SuperStruct" do
  5. described_class.ancestors.should include(SuperStruct)
  6. end
  7. describe "#initialize" do
  8. it "accepts an empty value" do
  9. lambda do
  10. i = described_class.new
  11. i.name.should be_nil
  12. end.should_not raise_error
  13. end
  14. it "accepts an empty hash" do
  15. lambda do
  16. i = described_class.new({})
  17. i.name.should be_nil
  18. end.should_not raise_error
  19. end
  20. # it "initializes a new instance from given params" do
  21. # i = described_class.new("ns1.example.com", "127.0.0.1")
  22. # i.name.should == "ns1.example.com"
  23. # i.ipv4.should == "127.0.0.1"
  24. # i.ipv6.should be_nil
  25. # end
  26. it "initializes a new instance from given hash" do
  27. i = described_class.new(:name => "ns1.example.com", :ipv4 => "127.0.0.1")
  28. i.name.should == "ns1.example.com"
  29. i.ipv4.should == "127.0.0.1"
  30. i.ipv6.should be_nil
  31. end
  32. it "initializes a new instance from given block" do
  33. i = described_class.new do |c|
  34. c.name = "ns1.example.com"
  35. c.ipv4 = "127.0.0.1"
  36. end
  37. i.name.should == "ns1.example.com"
  38. i.ipv4.should == "127.0.0.1"
  39. i.ipv6.should be_nil
  40. end
  41. end
  42. describe "#to_s" do
  43. it "returns the string representation of this object" do
  44. described_class.new(:name => "ns1.example.com").to_s.should == "ns1.example.com"
  45. described_class.new(:name => nil).to_s.should == ""
  46. described_class.new.to_s.should == ""
  47. end
  48. end
  49. end