aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/recaptcha/test
diff options
context:
space:
mode:
authorfrancis <francis>2008-10-17 11:32:31 +0000
committerfrancis <francis>2008-10-17 11:32:31 +0000
commit2f06e5a71e24ba9368c45346f4c23c84f6cfd058 (patch)
treef4e67513079631d98d208dc0d2699cf8fba1fecb /vendor/plugins/recaptcha/test
parentf2822d4f1451041ed845b2a24c23880e66d2ebc8 (diff)
reCAPTCHA plugin
Diffstat (limited to 'vendor/plugins/recaptcha/test')
-rw-r--r--vendor/plugins/recaptcha/test/recaptcha_test.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/plugins/recaptcha/test/recaptcha_test.rb b/vendor/plugins/recaptcha/test/recaptcha_test.rb
new file mode 100644
index 000000000..0373d25b1
--- /dev/null
+++ b/vendor/plugins/recaptcha/test/recaptcha_test.rb
@@ -0,0 +1,49 @@
+require 'test/unit'
+require 'builder'
+require File.dirname(__FILE__) + '/../lib/recaptcha'
+
+class ReCaptchaTest < Test::Unit::TestCase
+ include Ambethia::ReCaptcha
+ include Ambethia::ReCaptcha::Helper
+ include Ambethia::ReCaptcha::Controller
+
+ attr_accessor :session
+
+ def setup
+ @session = {}
+ ENV['RECAPTCHA_PUBLIC_KEY'] = '0000000000000000000000000000000000000000'
+ ENV['RECAPTCHA_PRIVATE_KEY'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
+ end
+
+ def test_recaptcha_tags
+ # Might as well match something...
+ assert_match /http:\/\/api.recaptcha.net/, recaptcha_tags
+ end
+
+ def test_recaptcha_tags_with_ssl
+ assert_match /https:\/\/api-secure.recaptcha.net/, recaptcha_tags(:ssl => true)
+ end
+
+ def test_recaptcha_tags_without_noscript
+ assert_no_match /noscript/, recaptcha_tags(:noscript => false)
+ end
+
+ def test_should_raise_exception_without_public_key
+ assert_raise ReCaptchaError do
+ ENV['RECAPTCHA_PUBLIC_KEY'] = nil
+ recaptcha_tags
+ end
+ end
+
+ def test_should_raise_exception_without_private_key
+ assert_raise ReCaptchaError do
+ ENV['RECAPTCHA_PRIVATE_KEY'] = nil
+ verify_recaptcha
+ end
+ end
+
+ def test_should_verify_recaptcha
+ # TODO Mock this, or figure something out...
+ end
+
+end