Skip to content

Commit

Permalink
Reorder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rorymckinley committed Nov 4, 2012
1 parent 2f128c6 commit fa5ef51
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 161 deletions.
49 changes: 27 additions & 22 deletions lib/whois/record/parser/whois.registry.net.za.rb
Expand Up @@ -17,6 +17,24 @@ class Parser
class WhoisRegistryNetZa < Base
include Scanners::Nodable

property_supported :disclaimer do
node(:disclaimer)
end

property_supported :domain do
node(:domain_name)
end

property_not_supported :domain_id

property_not_supported :referral_whois

property_not_supported :referral_url

property_supported :status do
node(:status)
end

property_supported :available? do
node(:available) ? true : false
end
Expand All @@ -25,24 +43,16 @@ class WhoisRegistryNetZa < Base
!available?
end

property_supported :domain do
node(:domain_name)
end

property_supported :created_on do
parse_date(node(:registration_date))
end

property_not_supported :updated_on

property_supported :expires_on do
parse_date(node(:renewal_date))
end

property_supported :nameservers do
Array.wrap(node(:nameservers)).map do |nameserver|
Record::Nameserver.new(:name => nameserver)
end
end

property_supported :registrar do
node(:registrar_id) do
Whois::Record::Registrar.new(:name => node(:registrar_name), :id => node(:registrar_id))
Expand All @@ -56,21 +66,16 @@ class WhoisRegistryNetZa < Base
end
end

property_supported :status do
node(:status)
end

property_supported :disclaimer do
node(:disclaimer)
end

property_not_supported :domain_id
property_not_supported :referral_whois
property_not_supported :referral_url
property_not_supported :updated_on
property_not_supported :admin_contacts

property_not_supported :technical_contacts

property_supported :nameservers do
Array.wrap(node(:nameservers)).map do |nameserver|
Record::Nameserver.new(:name => nameserver)
end
end

def parse
Scanners::WhoisRegistryNetZa.new(content_for_scanner).parse
end
Expand Down
@@ -1,47 +1,53 @@
#available?
should: %s == true

#registered?
should: %s == false

#nameservers
should: %s == []

#registrar
#disclaimer
should: %s == nil

#registrant_contacts
should: %s == []

#domain
should: %s == nil

#created_on
should: %s == nil

#status
should: %s == nil

#expires_on
should: %s == nil

#disclaimer
should: %s == nil

#domain_id
should: %s raise_error Whois::PropertyNotSupported


#referral_whois
should: %s raise_error Whois::PropertyNotSupported

#referral_url
should: %s raise_error Whois::PropertyNotSupported


#status
should: %s == nil

#available?
should: %s == true

#registered?
should: %s == false


#created_on
should: %s == nil

#updated_on
should: %s raise_error Whois::PropertyNotSupported

#expires_on
should: %s == nil


#registrar
should: %s == nil

#registrant_contacts
should: %s == []

#admin_contacts
should: %s raise_error Whois::PropertyNotSupported

#technical_contacts
should: %s raise_error Whois::PropertyNotSupported


#nameservers
should: %s == []
@@ -1,18 +1,40 @@
#disclaimer
should: %s == "The use of this Whois facility is subject to the following terms and\nconditions. https://registry.net.za/whois_terms\nCopyright (c) UniForum SA 1995-2012\n"


#domain
should: %s == "broccoliwafflesareawesome.co.za"

#domain_id
should: %s raise_error Whois::PropertyNotSupported


#referral_whois
should: %s raise_error Whois::PropertyNotSupported

#referral_url
should: %s raise_error Whois::PropertyNotSupported


#status
should: %s == ['ok', 'autorenew']

#available?
should: %s == false

#registered?
should: %s == true

#nameservers
should: %s CLASS(array)
should: %s SIZE(3)
should: %s[0] CLASS(nameserver)
should: %s[0].name == "ns2.host-h.net"
should: %s[1] CLASS(nameserver)
should: %s[1].name == "ns1.dns-h.com"
should: %s[2] CLASS(nameserver)
should: %s[2].name == "ns1.host-h.net"

#created_on
should: %s == Time.parse("2012-03-27")

#updated_on
should: %s raise_error Whois::PropertyNotSupported

#expires_on
should: %s == Time.parse("2013-03-27")


#registrar
should: %s CLASS(registrar)
Expand All @@ -30,35 +52,19 @@
should: %s[0].fax == "+27.219001000"
should: %s[0].address == "30 Frazzita Business Park Durbanville Cape Town ZA 7550"

#domain
should: %s == "broccoliwafflesareawesome.co.za"

#created_on
should: %s == Time.parse("2012-03-27")

#status
should: %s == ['ok', 'autorenew']

#expires_on
should: %s == Time.parse("2013-03-27")

#disclaimer
should: %s == "The use of this Whois facility is subject to the following terms and\nconditions. https://registry.net.za/whois_terms\nCopyright (c) UniForum SA 1995-2012\n"

#domain_id
should: %s raise_error Whois::PropertyNotSupported

#referral_whois
should: %s raise_error Whois::PropertyNotSupported

#referral_url
should: %s raise_error Whois::PropertyNotSupported

#updated_on
should: %s raise_error Whois::PropertyNotSupported

#admin_contacts
should: %s raise_error Whois::PropertyNotSupported

#technical_contacts
should: %s raise_error Whois::PropertyNotSupported


#nameservers
should: %s CLASS(array)
should: %s SIZE(3)
should: %s[0] CLASS(nameserver)
should: %s[0].name == "ns2.host-h.net"
should: %s[1] CLASS(nameserver)
should: %s[1].name == "ns1.dns-h.com"
should: %s[2] CLASS(nameserver)
should: %s[2].name == "ns1.host-h.net"
Expand Up @@ -21,74 +21,69 @@
described_class.new(part)
end

describe "#available?" do
it do
subject.available?.should == true
end
end
describe "#registered?" do
describe "#disclaimer" do
it do
subject.registered?.should == false
subject.disclaimer.should == nil
end
end
describe "#nameservers" do
describe "#domain" do
it do
subject.nameservers.should == []
subject.domain.should == nil
end
end
describe "#registrar" do
describe "#domain_id" do
it do
subject.registrar.should == nil
lambda { subject.domain_id }.should raise_error Whois::PropertyNotSupported
end
end
describe "#registrant_contacts" do
describe "#referral_whois" do
it do
subject.registrant_contacts.should == []
lambda { subject.referral_whois }.should raise_error Whois::PropertyNotSupported
end
end
describe "#domain" do
describe "#referral_url" do
it do
subject.domain.should == nil
lambda { subject.referral_url }.should raise_error Whois::PropertyNotSupported
end
end
describe "#created_on" do
describe "#status" do
it do
subject.created_on.should == nil
subject.status.should == nil
end
end
describe "#status" do
describe "#available?" do
it do
subject.status.should == nil
subject.available?.should == true
end
end
describe "#expires_on" do
describe "#registered?" do
it do
subject.expires_on.should == nil
subject.registered?.should == false
end
end
describe "#disclaimer" do
describe "#created_on" do
it do
subject.disclaimer.should == nil
subject.created_on.should == nil
end
end
describe "#domain_id" do
describe "#updated_on" do
it do
lambda { subject.domain_id }.should raise_error Whois::PropertyNotSupported
lambda { subject.updated_on }.should raise_error Whois::PropertyNotSupported
end
end
describe "#referral_whois" do
describe "#expires_on" do
it do
lambda { subject.referral_whois }.should raise_error Whois::PropertyNotSupported
subject.expires_on.should == nil
end
end
describe "#referral_url" do
describe "#registrar" do
it do
lambda { subject.referral_url }.should raise_error Whois::PropertyNotSupported
subject.registrar.should == nil
end
end
describe "#updated_on" do
describe "#registrant_contacts" do
it do
lambda { subject.updated_on }.should raise_error Whois::PropertyNotSupported
subject.registrant_contacts.should == []
end
end
describe "#admin_contacts" do
Expand All @@ -101,4 +96,9 @@
lambda { subject.technical_contacts }.should raise_error Whois::PropertyNotSupported
end
end
describe "#nameservers" do
it do
subject.nameservers.should == []
end
end
end

0 comments on commit fa5ef51

Please sign in to comment.