Permalink
Browse files

make error messages more informative

  • Loading branch information...
1 parent 95d9b28 commit 0f0bf135609e06793e843479ab97c803de046963 @NARKOZ committed Mar 18, 2012
Showing with 7 additions and 7 deletions.
  1. +2 −2 lib/whoaz.rb
  2. +1 −1 lib/whoaz/whois.rb
  3. +4 −4 spec/whoaz/whois_spec.rb
View
@@ -18,8 +18,8 @@ module Whoaz
# @return [Whoaz::Whois]
def self.whois(domain='')
domain = domain.to_s.strip.downcase
- raise EmptyDomain, "Domain not specified" if domain.empty?
- raise InvalidDomain, "Domain contains non-ASCII characters" unless domain.ascii_only?
+ raise EmptyDomain, "Domain name is not specified" if domain.empty?
+ raise InvalidDomain, "Domain name contains non-ASCII characters" unless domain.ascii_only?
Whoaz::Whois.new(domain)
end
end
View
@@ -82,7 +82,7 @@ def registered?
def query
post_domain = @domain.split('.', 2)
- raise InvalidDomain, "Invalid domain specified" unless
+ raise InvalidDomain, "Invalid domain name is specified" unless
[MAIN_TLD, REGIONAL_TLD].any? {|a| a.include? post_domain.last}
url = URI WHOIS_URL
View
@@ -6,15 +6,15 @@
describe "empty domain query" do
it "should raise EmptyDomain" do
- expect { Whoaz.whois }.to raise_error Whoaz::EmptyDomain, 'Domain not specified'
+ expect { Whoaz.whois }.to raise_error Whoaz::EmptyDomain, 'Domain name is not specified'
end
end
describe "invalid domain query" do
it "should raise InvalidDomain" do
- expect { Whoaz.whois 'google' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain specified'
- expect { Whoaz.whois 'goo.gl' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain specified'
- expect { Whoaz.whois 'алм.az' }.to raise_error Whoaz::InvalidDomain, 'Domain contains non-ASCII characters'
+ expect { Whoaz.whois 'google' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain name is specified'
+ expect { Whoaz.whois 'goo.gl' }.to raise_error Whoaz::InvalidDomain, 'Invalid domain name is specified'
+ expect { Whoaz.whois 'алм.az' }.to raise_error Whoaz::InvalidDomain, 'Domain name contains non-ASCII characters'
end
end

0 comments on commit 0f0bf13

Please sign in to comment.