test/test_demandbase.rb in demandbase-0.1.4 vs test/test_demandbase.rb in demandbase-0.1.5

- old
+ new

@@ -1,49 +1,22 @@ require 'helper' class TestDemandbase < Test::Unit::TestCase - should "get a record for Stanford University" do - #assert_equal 'Stanford University', Demandbase::lookup_domain('stanford.edu') + should "get a record for Stanford University's domain name" do + assert_equal 'Stanford', Demandbase::lookup_domain('stanford.edu').company_name end - should "get a record for the University of Strathclyde" do - + should "get a record for a Stanford Uniersity IP" do + assert_equal 'Stanford Uniersity', Demandbase::lookup_ip('68.65.169.67').company_name # typo intentional end - should "get a record for a GitHub's IP address" do - + should "be able to lazily lookup" do + assert_equal "Demandbase::IPRecord", Demandbase::lookup('68.65.169.67').class.to_s + assert_equal "Demandbase::DomainRecord", Demandbase::lookup('github.com').class.to_s end - should "recognize IP addresses" do - - end - - should "recognize domain names" do - - end - - should "handle multiple formats" do - queries = [ - "microsoft.com", - "www.microsoft.com", - "developer.hacks.microsoft.com", - "http://www.microsoft.com", - "https://www.microsofot.com", - "william.gates@microsoft.com", - "microsoft.co.uk" - ] - end - - should "return nothing when no record is found" do - - end - - should "throw an exception when the service is down" do - - end - - should "know a school" do + should "know a school by domain name" do schools = [ 'strath.ac.uk', 'stanford.edu', 'walnutcreeksd.org' ] @@ -57,9 +30,55 @@ assert_equal true, Demandbase::is_academic?(school) end not_schools.each do |school| assert_equal false, Demandbase::is_academic?(school) + end + end + + should "know a goverment agency / body by domain name" do + government_agencies = [ + 'jgi.doe.gov', + 'cia.gov', + 'glasgow.gov.uk', + #'lanl.gov' + #'gchq.gov.uk' + ] + + non_government_agencies = [ + 'rangers.co.uk', + 'leereilly.net' + ] + + government_agencies.each do |government_agency| + assert_equal true, Demandbase::is_government?(government_agency), government_agency + end + + non_government_agencies.each do |non_government_agency| + assert_equal false, Demandbase::is_government?(non_government_agency), non_government_agency + end + end + + should "know a nonprofit by domain name" do + nonprofits = [ + 'gatesfoundation.org', + 'bhf.org.uk' + #'rspca.org.uk', + #'runningchicken.org' + + ] + + non_nonprofits = [ # nonprofit + 'rangers.co.uk', + 'leereilly.net' + ] + + nonprofits.each do |nonprofit| + assert_equal true, Demandbase::is_nonprofit?(nonprofit), nonprofit + end + + non_nonprofits.each do |non_nonprofit| + assert_equal false, Demandbase::is_nonprofit?(non_nonprofit), non_nonprofit end end end