aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/recaptcha/test/recaptcha_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/plugins/recaptcha/test/recaptcha_test.rb')
-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