blob: 0373d25b15a883a255f33cd278867dbd86c4e8dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
|