test/test_swot.rb in swot-0.2.13 vs test/test_swot.rb in swot-0.3.0

- old
+ new

@@ -1,5 +1,6 @@ +# encoding: UTF-8 require 'helper' class TestEmail < Test::Unit::TestCase should "recognizes academic email addresses and domains" do assert_equal Swot::is_academic?('lreilly@stanford.edu'), true @@ -19,12 +20,12 @@ assert_equal Swot::is_academic?('lee@strath.ac.uk.com'), false assert_equal Swot::is_academic?('stanford.edu'), true assert_equal Swot::is_academic?('slac.stanford.edu'), true assert_equal Swot::is_academic?('www.stanford.edu'), true - #assert_equal Swot::is_academic?('http://www.stanford.edu'), true - #assert_equal Swot::is_academic?('http://www.stanford.edu:9393'), true + assert_equal Swot::is_academic?('http://www.stanford.edu'), true + assert_equal Swot::is_academic?('http://www.stanford.edu:9393'), true assert_equal Swot::is_academic?('strath.ac.uk'), true assert_equal Swot::is_academic?('soft-eng.strath.ac.uk'), true assert_equal Swot::is_academic?('ugr.es'), true assert_equal Swot::is_academic?('uottawa.ca'), true assert_equal Swot::is_academic?('mother.edu.ru'), true @@ -44,12 +45,23 @@ assert_equal Swot::is_academic?(' gmail.com '), false end should "returns name of valid institution" do assert_equal Swot::get_institution_name('lreilly@cs.strath.ac.uk'), "University of Strathclyde" + assert_equal Swot::get_institution_name('lreilly@fadi.at'), "BRG Fadingerstraße Linz, Austria" end + should "returns nil when institution invalid" do + assert_equal Swot::get_institution_name('foo@shop.com'), nil + end + should "test aliased methods" do assert_equal Swot::academic?('stanford.edu'), true assert_equal Swot::school_name('lreilly@cs.strath.ac.uk'), "University of Strathclyde" + end + + should "fail blacklisted domains" do + ["si.edu", " si.edu ", "imposter@si.edu"].each do |domain| + assert_equal false, Swot::is_academic?(domain), "#{domain} should be denied" + end end end