Merge pull request #6 from johndbritton/master

Add tests and make sure they pass
This commit is contained in:
Lee Reilly 2012-09-11 16:50:56 -07:00
commit 8a348bcc9a
2 changed files with 5 additions and 3 deletions

View File

@ -131,8 +131,8 @@ module Swot
# Returns true if the domain name belongs to an academic institution;
# false oterwise.
def is_academic?(text)
text.strip!
return false if text.nil?
text.strip!
begin
domain = get_domain(text)
return false if domain.nil?
@ -169,7 +169,6 @@ module Swot
# Returns true if the domain name belongs to a known academic instition;
# false otherwise.
def match_academic_domain?(domain)
domain.strip!
File.exists?("#{File.expand_path(__FILE__+'/..')}/domains/#{domain.tld}/#{domain.sld}")
end
@ -177,7 +176,6 @@ module Swot
#
# Return the institution name, or nil if not found.
def name_from_academic_domain(domain)
domain.strip!
begin
file = File.open("#{File.expand_path(__FILE__+'/..')}/domains/#{domain.tld}/#{domain.sld}", "rb")
contents = file.read

View File

@ -38,6 +38,10 @@ class TestEmail < Test::Unit::TestCase
assert_equal Swot::is_academic?(nil), false
assert_equal Swot::is_academic?(''), false
assert_equal Swot::is_academic?('the'), false
assert_equal Swot::is_academic?(' stanford.edu'), true
assert_equal Swot::is_academic?('lee@strath.ac.uk '), true
assert_equal Swot::is_academic?(' gmail.com '), false
end
should "returns name of valid institution" do