test/test_jabber.rb in messenger-0.0.3 vs test/test_jabber.rb in messenger-0.1.0
- old
+ new
@@ -26,9 +26,37 @@
should "fail if the recipient is not subscribed" do
::Jabber::Simple.expects(:new).with("notifier@zencoder.com", "asdfasdf", nil).returns(@failed_jabber)
result = Jabber.send("jabber://brandon@zencoder.com", "Test message", :jabber_id => "notifier@zencoder.com", :jabber_password => "asdfasdf")
assert_equal [false, "Not yet authorized"], result
end
+
+ should "raise when sending to an invalid URL" do
+ assert_raises URLError do
+ Jabber.send("jabber://", :jabber_id => "asdf", :jabber_password => "asdf")
+ end
+ end
+
+ should "obfuscate the URL" do
+ assert_equal "jabber://test@example.com", Jabber.obfuscate("jabber://test@example.com")
+ end
+
+ should "raise when obfuscating an invalid URL" do
+ assert_raises URLError do
+ Jabber.obfuscate("jabber://")
+ end
+ end
+ end
+
+ context "Jabber URL validation" do
+ should "return true for good URLs" do
+ assert true, Jabber.valid_url?("jabber://test@example.com")
+ end
+
+ should "return false for bad URLs" do
+ assert_equal false, Jabber.valid_url?("jabber://!")
+ assert_equal false, Jabber.valid_url?("jabber://test")
+ assert_equal false, Jabber.valid_url?("jabber://example.com")
+ end
end
end
end