Skip to content

Commit

Permalink
Shift company when it is injected into the address
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Feb 27, 2011
1 parent 65395c3 commit 624463b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/whois/answer/parser/whois.nic.it.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ def parse
def contact(element, type)
node(element) do |raw|
address = (raw["Address"] || "").split("\n")
company = address.size == 6 ? address.shift : nil
Answer::Contact.new(
:id => raw["ContactID"],
:type => type,
:name => raw["Name"],
:organization => raw["Organization"],
:organization => raw["Organization"] || company,
:address => address[0],
:city => address[1],
:zip => address[2],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#technical_contact
should: %s be_a(_contact)
should: %s.type == Whois::Answer::Contact::TYPE_TECHNICAL
should: %s.id == "AARS1-ITNIC"
should: %s.name == "Andrea Antonio Renato Stratta"
should: %s.organization == "UCI Italia Srl"
should: %s.address == "Via E. Fermi, 161"
should: %s.city == "Roma"
should: %s.zip == "00146"
should: %s.state == "RM"
should: %s.country_code == "IT"
should: %s.created_on == Time.parse("2006-08-16 00:00:00")
should: %s.updated_on == Time.parse("2007-03-01 07:48:42")
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/whois/answer/parser/responses/whois.nic.it/property_contact_with_company_in_address_spec.rb
#
# and regenerate the tests with the following rake task
#
# $ rake genspec:parsers
#

require 'spec_helper'
require 'whois/answer/parser/whois.nic.it'

describe Whois::Answer::Parser::WhoisNicIt, "property_contact_with_company_in_address.expected" do

before(:each) do
file = fixture("responses", "whois.nic.it/property_contact_with_company_in_address.txt")
part = Whois::Answer::Part.new(:body => File.read(file))
@parser = klass.new(part)
end

context "#technical_contact" do
it do
@parser.technical_contact.should be_a(_contact)
end
it do
@parser.technical_contact.type.should == Whois::Answer::Contact::TYPE_TECHNICAL
end
it do
@parser.technical_contact.id.should == "AARS1-ITNIC"
end
it do
@parser.technical_contact.name.should == "Andrea Antonio Renato Stratta"
end
it do
@parser.technical_contact.organization.should == "UCI Italia Srl"
end
it do
@parser.technical_contact.address.should == "Via E. Fermi, 161"
end
it do
@parser.technical_contact.city.should == "Roma"
end
it do
@parser.technical_contact.zip.should == "00146"
end
it do
@parser.technical_contact.state.should == "RM"
end
it do
@parser.technical_contact.country_code.should == "IT"
end
it do
@parser.technical_contact.created_on.should == Time.parse("2006-08-16 00:00:00")
end
it do
@parser.technical_contact.updated_on.should == Time.parse("2007-03-01 07:48:42")
end
end
end

0 comments on commit 624463b

Please sign in to comment.