test/test_bitly.rb in philnash-bitly-0.1.1 vs test/test_bitly.rb in philnash-bitly-0.1.2
- old
+ new
@@ -36,6 +36,25 @@
assert_equal url2.class, Bitly::Url
assert_equal url2.hash, "wQaT"
assert_equal url2.short_url, "http://bit.ly/wQaT"
assert_equal url2.long_url, "http://google.com/"
end
-end
\ No newline at end of file
+
+ def test_returns_keyword_url
+ #kind of ghetto test but we need it to be different every time
+ require 'digest/sha1'
+ keyword = Digest::SHA1.hexdigest(DateTime.now.to_s)
+
+ url = @bitly.shorten("http://google.com", keyword)
+ assert_equal url.short_keyword_url, "http://bit.ly/#{keyword}"
+ end
+
+ def test_returns_error_on_existing_keyword
+ keyword = 'apple'
+ assert_raise BitlyError do
+ @bitly.shorten("http://apple.com/itunes", keyword)
+ end
+ end
+
+
+
+end