test/test_libravatar.rb in vishnu-1.2.1 vs test/test_libravatar.rb in vishnu-1.2.2

- old
+ new

@@ -3,21 +3,21 @@ class TestLibravatar < Test::Unit::TestCase should "Generate url from email" do # echo -n "user@example.com"|md5sum # => b58996c504c5638798eb6b511e6f49af avatar = Libravatar.new(:email => "user@example.com") - assert_equal avatar.to_s, "http://cdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af" - assert_equal Libravatar.new(:email => "USER@ExAmPlE.CoM").to_s, "http://cdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af" + re = /http:\/\/.+\/avatar\/b58996c504c5638798eb6b511e6f49af$/ + assert avatar.to_s.match(re) + assert Libravatar.new(:email => "USER@ExAmPlE.CoM").to_s.match(re) - assert_equal Libravatar.new(:email => "user@example.com", :https => true).to_s, "https://seccdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af" + assert_equal Libravatar.new(:email => "user@example.com", :https => true).to_s[0,8], "https://" + assert_equal Libravatar.new(:email => "user@example.com", :https => false).to_s[0,7], "http://" - assert_equal Libravatar.new(:email => "user@example.com", :https => false).to_s, "http://cdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af" + assert Libravatar.new(:email => "USER@ExAmPlE.CoM", :default => "http://example.com/avatar.png").to_s.match(/http:\/\/.+\/avatar\/b58996c504c5638798eb6b511e6f49af\?d=http:\/\/example\.com\/avatar\.png/) - assert_equal Libravatar.new(:email => "USER@ExAmPlE.CoM", :default => "http://example.com/avatar.png").to_s, "http://cdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af?d=http://example.com/avatar.png" - - assert_equal Libravatar.new(:email => "USER@ExAmPlE.CoM", :size => 512, :default => "mm").to_s, "http://cdn.libravatar.org/avatar/b58996c504c5638798eb6b511e6f49af?s=512&d=mm" + assert_equal Libravatar.new(:email => "USER@ExAmPlE.CoM", :size => 512, :default => "mm").to_s[-43,43], "b58996c504c5638798eb6b511e6f49af?s=512&d=mm" end should "Generate url from openid" do # echo -n "http://example.com/id/Bob"|shasum -a 256 # => 80cd0679bb52beac4d5d388c163016dbc5d3f30c262a4f539564236ca9d49ccd @@ -32,16 +32,15 @@ end should "Normalize OpenID" do x = Libravatar.new assert_equal x.send(:normalize_openid, "HTTP://EXAMPLE.COM/id/Bob"), "http://example.com/id/Bob" - assert_equal x.send(:normalize_openid, "HTTP://EXAMPLE.COM"), "http://example.com/" end should "Return the federated URI" do avatar = Libravatar.new(:email => 'invalid@catalyst.net.nz') - assert_equal avatar.to_s, 'http://static.avatars.catalyst.net.nz/avatar/f924d1e9f2c10ee9efa7acdd16484c2f' + assert avatar.to_s.match(/http:\/\/.+\/avatar\/f924d1e9f2c10ee9efa7acdd16484c2f$/) end should "Sanitize the SRV lookup result" do avatar = Libravatar.new assert_equal ["hosntame.abcde.fghi.com", 12345], avatar.send(:sanitize_srv_lookup, "hosntame.abcde.fghi.com", 12345)