recaptcha 0.3.1 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ rdoc
2
+ pkg
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.3.4 / 2011-12-13
2
+
3
+ * Rails 3
4
+ * Remove jeweler
5
+
1
6
  == 0.2.2 / 2009-09-14
2
7
 
3
8
  * Add a timeout to the validator
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ recaptcha (0.3.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activesupport (3.1.3)
10
+ multi_json (~> 1.0)
11
+ i18n (0.6.0)
12
+ metaclass (0.0.1)
13
+ mocha (0.10.0)
14
+ metaclass (~> 0.0.1)
15
+ multi_json (1.0.3)
16
+ rake (0.9.2.2)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ activesupport
23
+ i18n
24
+ mocha
25
+ rake
26
+ recaptcha!
@@ -23,7 +23,11 @@ Hoptoad}[http://robots.thoughtbot.com/post/344833329/mygem-configure-block].
23
23
 
24
24
  == Rails Installation
25
25
 
26
- reCAPTCHA for Rails can be installed as a gem:
26
+ reCAPTCHA for Rails, add this to your Gemfile:
27
+
28
+ gem "recaptcha", :require => "recaptcha/rails"
29
+
30
+ Or, it can be installed as a gem:
27
31
 
28
32
  config.gem "recaptcha", :lib => "recaptcha/rails"
29
33
 
@@ -52,11 +56,20 @@ into a +config/initializers/recaptcha.rb+ when used in a Rails project.
52
56
  Recaptcha.configure do |config|
53
57
  config.public_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
54
58
  config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
59
+ config.proxy = 'http://myrpoxy.com.au:8080'
55
60
  end
56
61
 
57
62
  This way, you may also set additional options to fit recaptcha into your
58
63
  deployment environment.
59
64
 
65
+ == Recaptcha#with_configuration
66
+
67
+ If you want to temporarily overwrite the configuration you set with `Recaptcha.configure` (when testing, for example), you can use a `Recaptcha#with_configuration` block:
68
+
69
+ Recaptcha.configure(:public_key => '12345') do
70
+ # Do stuff with the overwritten public_key.
71
+ end
72
+
60
73
  === Shell environment
61
74
 
62
75
  Or, you can keep your keys out of your code base by exporting the following
@@ -79,7 +92,13 @@ and later,
79
92
  This option might be useful, if the same code base is used for multiple
80
93
  reCAPTCHA setups.
81
94
 
82
- == +recaptcha_tags+
95
+ == To use 'recaptcha'
96
+
97
+ Add +recaptcha_tags+ to each form you want to protect.
98
+
99
+ And, add +verify_recaptcha+ logic to each form action that you've protected.
100
+
101
+ === +recaptcha_tags+
83
102
 
84
103
  Some of the options available:
85
104
 
@@ -93,10 +112,10 @@ Some of the options available:
93
112
  You can also override the html attributes for the sizes of the generated +textarea+ and +iframe+
94
113
  elements, if CSS isn't your thing. Inspect the source of +recaptcha_tags+ to see these options.
95
114
 
96
- == +verify_recaptcha+
115
+ === +verify_recaptcha+
97
116
 
98
117
  This method returns +true+ or +false+ after processing the parameters from the reCAPTCHA widget. Why
99
- isn't this a model validation? Because that violates MVC. Use can use it like this, or how ever you
118
+ isn't this a model validation? Because that violates MVC. You can use it like this, or how ever you
100
119
  like. Passing in the ActiveRecord object is optional, if you do--and the captcha fails to verify--an
101
120
  error will be added to the object for you to use.
102
121
 
@@ -116,6 +135,14 @@ Some of the options available:
116
135
  end
117
136
  end
118
137
 
138
+ == I18n support
139
+ reCAPTCHA passes two types of error explanation to a linked model. It will use the I18n gem
140
+ to translate the default error message if I18n is available. To customize the messages to your locale,
141
+ add these keys to your I18n backend:
142
+
143
+ <tt>recaptcha.errors.verification_failed</tt>:: error message displayed if the captcha words didn't match
144
+ <tt>recaptcha.errors.recaptcha_unavailable</tt>:: displayed if a timout error occured while attempting to verify the captcha
145
+
119
146
  == TODO
120
147
  * Remove Rails/ActionController dependencies
121
148
  * Framework agnostic
data/Rakefile CHANGED
@@ -1,60 +1,9 @@
1
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
2
3
 
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |gem|
6
- gem.name = "recaptcha"
7
- gem.description = "This plugin adds helpers for the reCAPTCHA API "
8
- gem.summary = "Helpers for the reCAPTCHA API"
9
- gem.homepage = "http://ambethia.com/recaptcha"
10
- gem.authors = ["Jason L. Perry"]
11
- gem.email = "jasper@ambethia.com"
12
- gem.files.reject! { |fn| fn.include? ".gitignore" }
13
- gem.add_development_dependency "mocha"
14
- gem.add_development_dependency "activesupport"
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require 'rake/rdoctask'
22
- Rake::RDocTask.new do |rd|
23
- if File.exist?('VERSION.yml')
24
- config = YAML.load(File.read('VERSION.yml'))
25
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
26
- else
27
- version = ""
28
- end
29
-
30
- rd.main = "README.rdoc"
31
- rd.rdoc_files.include "README.rdoc", "LICENSE", "lib/**/*.rb"
32
- rd.rdoc_dir = 'rdoc'
33
- rd.options << '-N' # line numbers
34
- rd.options << '-S' # inline source
35
- end
36
-
37
- require 'rake/testtask'
38
- Rake::TestTask.new(:test) do |test|
39
- test.libs << 'test'
40
- test.pattern = 'test/**/*_test.rb'
41
- # test.verbose = true
42
- end
43
-
44
- begin
45
- require 'rcov/rcovtask'
46
- Rcov::RcovTask.new do |test|
47
- test.libs << 'test'
48
- test.pattern = 'test/**/*_test.rb'
49
- test.verbose = true
50
- end
51
- rescue LoadError
52
- task :rcov do
53
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
54
- end
4
+ Rake::TestTask.new :test do |test|
5
+ test.libs << "lib"
6
+ test.pattern = "test/*_test.rb"
55
7
  end
56
8
 
57
9
  task :default => :test
58
-
59
-
60
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/init.rb CHANGED
@@ -2,5 +2,4 @@
2
2
  # You can also install it as a gem:
3
3
  # config.gem "ambethia-recaptcha", :lib => "recaptcha/rails", :source => "http://gems.github.com"
4
4
 
5
- require 'net/http'
6
5
  require 'recaptcha/rails'
@@ -3,16 +3,6 @@ require 'recaptcha/client_helper'
3
3
  require 'recaptcha/verify'
4
4
 
5
5
  module Recaptcha
6
- module VERSION #:nodoc:
7
- MAJOR = 0
8
- MINOR = 2
9
- TINY = 2
10
- PATCH = 1
11
-
12
- STRING = [MAJOR, MINOR, TINY, PATCH].join('.')
13
- end
14
-
15
-
16
6
  RECAPTCHA_API_SERVER_URL = 'http://www.google.com/recaptcha/api'
17
7
  RECAPTCHA_API_SECURE_SERVER_URL = 'https://www.google.com/recaptcha/api'
18
8
  RECAPTCHA_VERIFY_URL = 'http://www.google.com/recaptcha/api/verify'
@@ -35,6 +25,24 @@ module Recaptcha
35
25
  yield(config)
36
26
  end
37
27
 
28
+ def self.with_configuration(config)
29
+ original_config = {}
30
+
31
+ config.each do |key, value|
32
+ original_config[key] = configuration.send(key)
33
+ configuration.send("#{key}=", value)
34
+ end
35
+
36
+ result = yield if block_given?
37
+
38
+ original_config.each { |key, value| configuration.send("#{key}=", value) }
39
+ result
40
+ end
41
+
38
42
  class RecaptchaError < StandardError
39
43
  end
40
44
  end
45
+
46
+ if defined?(Rails)
47
+ require 'recaptcha/rails'
48
+ end
@@ -15,11 +15,20 @@ module Recaptcha
15
15
  html << %{</script>\n}
16
16
  end
17
17
  if options[:ajax]
18
- html << %{<div id="dynamic_recaptcha"></div>}
19
- html << %{<script type="text/javascript" src="#{uri}/js/recaptcha_ajax.js"></script>\n}
20
- html << %{<script type="text/javascript">\n}
21
- html << %{ Recaptcha.create('#{key}', document.getElementById('dynamic_recaptcha')#{options[:display] ? ',RecaptchaOptions' : ''});}
22
- html << %{</script>\n}
18
+ html << <<-EOS
19
+ <div id="dynamic_recaptcha"></div>
20
+ <script type="text/javascript">
21
+ var rc_script_tag = document.createElement('script'),
22
+ rc_init_func = function(){Recaptcha.create("#{key}", document.getElementById("dynamic_recaptcha")#{',RecaptchaOptions' if options[:display]});}
23
+ rc_script_tag.src = "#{uri}/js/recaptcha_ajax.js";
24
+ rc_script_tag.type = 'text/javascript';
25
+ rc_script_tag.onload = function(){rc_init_func.call();};
26
+ rc_script_tag.onreadystatechange = function(){
27
+ if (rc_script_tag.readyState == 'loaded' || rc_script_tag.readyState == 'complete') {rc_init_func.call();}
28
+ };
29
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(rc_script_tag);
30
+ </script>
31
+ EOS
23
32
  else
24
33
  html << %{<script type="text/javascript" src="#{uri}/challenge?k=#{key}}
25
34
  html << %{#{error ? "&amp;error=#{CGI::escape(error)}" : ""}"></script>\n}
@@ -36,7 +45,7 @@ module Recaptcha
36
45
  html << %{</noscript>\n}
37
46
  end
38
47
  end
39
- return html.html_safe
48
+ return (html.respond_to?(:html_safe) && html.html_safe) || html
40
49
  end # recaptcha_tags
41
50
  end # ClientHelper
42
51
  end # Recaptcha
@@ -33,7 +33,8 @@ module Recaptcha
33
33
  :verify_url,
34
34
  :skip_verify_env,
35
35
  :private_key,
36
- :public_key
36
+ :public_key,
37
+ :proxy
37
38
 
38
39
  def initialize #:nodoc:
39
40
  @nonssl_api_server_url = RECAPTCHA_API_SERVER_URL
@@ -1,3 +1,4 @@
1
+ require 'net/http'
1
2
  require 'recaptcha'
2
3
 
3
4
  ActionView::Base.send(:include, Recaptcha::ClientHelper)
@@ -0,0 +1,15 @@
1
+ require 'net/http'
2
+ require 'recaptcha'
3
+ module Rails
4
+ module Recaptcha
5
+ class Railtie < Rails::Railtie
6
+ initializer "setup config" do
7
+ begin
8
+ ActionView::Base.send(:include, ::Recaptcha::ClientHelper)
9
+ ActionController::Base.send(:include, ::Recaptcha::Verify)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -1,3 +1,4 @@
1
+ require "uri"
1
2
  module Recaptcha
2
3
  module Verify
3
4
  # Your private API can be specified in the +options+ hash or preferably
@@ -6,41 +7,50 @@ module Recaptcha
6
7
  if !options.is_a? Hash
7
8
  options = {:model => options}
8
9
  end
9
-
10
+
10
11
  env = options[:env] || ENV['RAILS_ENV']
11
12
  return true if Recaptcha.configuration.skip_verify_env.include? env
12
13
  model = options[:model]
13
14
  attribute = options[:attribute] || :base
14
15
  private_key = options[:private_key] || Recaptcha.configuration.private_key
15
16
  raise RecaptchaError, "No private key specified." unless private_key
16
-
17
+
17
18
  begin
18
19
  recaptcha = nil
20
+ if(Recaptcha.configuration.proxy)
21
+ proxy_server = URI.parse(Recaptcha.configuration.proxy)
22
+ http = Net::HTTP::Proxy(proxy_server.host, proxy_server.port, proxy_server.user, proxy_server.password)
23
+ else
24
+ http = Net::HTTP
25
+ end
26
+
19
27
  Timeout::timeout(options[:timeout] || 3) do
20
- recaptcha = Net::HTTP.post_form URI.parse(Recaptcha.configuration.verify_url), {
28
+ recaptcha = http.post_form(URI.parse(Recaptcha.configuration.verify_url), {
21
29
  "privatekey" => private_key,
22
30
  "remoteip" => request.remote_ip,
23
31
  "challenge" => params[:recaptcha_challenge_field],
24
32
  "response" => params[:recaptcha_response_field]
25
- }
33
+ })
26
34
  end
27
35
  answer, error = recaptcha.body.split.map { |s| s.chomp }
28
36
  unless answer == 'true'
29
37
  flash[:recaptcha_error] = error
30
38
  if model
31
- model.valid?
32
- model.errors.add attribute, options[:message] || "Word verification response is incorrect, please try again."
39
+ message = "Word verification response is incorrect, please try again."
40
+ message = I18n.translate(:'recaptcha.errors.verification_failed', {:default => message}) if defined?(I18n)
41
+ model.errors.add attribute, options[:message] || message
33
42
  end
34
43
  return false
35
44
  else
36
45
  flash[:recaptcha_error] = nil
37
46
  return true
38
47
  end
39
- rescue Timeout::Error
48
+ rescue Timeout::Error
40
49
  flash[:recaptcha_error] = "recaptcha-not-reachable"
41
50
  if model
42
- model.valid?
43
- model.errors.add attribute, options[:message] || "Oops, we failed to validate your word verification response. Please try again."
51
+ message = "Oops, we failed to validate your word verification response. Please try again."
52
+ message = I18n.translate(:'recaptcha.errors.recaptcha_unreachable', :default => message) if defined?(I18n)
53
+ model.errors.add attribute, options[:message] || message
44
54
  end
45
55
  return false
46
56
  rescue Exception => e
@@ -0,0 +1,3 @@
1
+ module Recaptcha
2
+ VERSION = "0.3.4"
3
+ end
@@ -1,62 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "recaptcha/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{recaptcha}
8
- s.version = "0.3.1"
6
+ s.name = "recaptcha"
7
+ s.version = Recaptcha::VERSION
8
+ s.authors = ["Jason L Perry"]
9
+ s.email = ["jasper@ambethia.com"]
10
+ s.homepage = "http://github.com/ambethia/recaptcha"
11
+ s.summary = %q{Helpers for the reCAPTCHA API}
12
+ s.description = %q{This plugin adds helpers for the reCAPTCHA API}
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jason L. Perry"]
12
- s.date = %q{2010-12-20}
13
- s.description = %q{This plugin adds helpers for the reCAPTCHA API }
14
- s.email = %q{jasper@ambethia.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- "CHANGELOG",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "init.rb",
26
- "lib/recaptcha.rb",
27
- "lib/recaptcha/client_helper.rb",
28
- "lib/recaptcha/configuration.rb",
29
- "lib/recaptcha/merb.rb",
30
- "lib/recaptcha/rails.rb",
31
- "lib/recaptcha/verify.rb",
32
- "recaptcha.gemspec",
33
- "tasks/recaptcha_tasks.rake",
34
- "test/recaptcha_test.rb",
35
- "test/verify_recaptcha_test.rb"
36
- ]
37
- s.homepage = %q{http://ambethia.com/recaptcha}
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.7}
40
- s.summary = %q{Helpers for the reCAPTCHA API}
41
- s.test_files = [
42
- "test/recaptcha_test.rb",
43
- "test/verify_recaptcha_test.rb"
44
- ]
14
+ s.rubyforge_project = "recaptcha"
45
15
 
46
- if s.respond_to? :specification_version then
47
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
- s.specification_version = 3
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
49
19
 
50
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
- s.add_development_dependency(%q<mocha>, [">= 0"])
52
- s.add_development_dependency(%q<activesupport>, [">= 0"])
53
- else
54
- s.add_dependency(%q<mocha>, [">= 0"])
55
- s.add_dependency(%q<activesupport>, [">= 0"])
56
- end
57
- else
58
- s.add_dependency(%q<mocha>, [">= 0"])
59
- s.add_dependency(%q<activesupport>, [">= 0"])
60
- end
20
+ s.add_development_dependency "mocha"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "activesupport"
23
+ s.add_development_dependency "i18n"
61
24
  end
62
-
@@ -16,12 +16,12 @@ class RecaptchaClientHelperTest < Test::Unit::TestCase
16
16
  config.private_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
17
17
  end
18
18
  end
19
-
19
+
20
20
  def test_recaptcha_tags
21
21
  # Might as well match something...
22
22
  assert_match /http:\/\/www.google.com\/recaptcha\/api\/challenge/, recaptcha_tags
23
23
  end
24
-
24
+
25
25
  def test_recaptcha_tags_with_ssl
26
26
  assert_match /https:\/\/www.google.com\/recaptcha\/api\/challenge/, recaptcha_tags(:ssl => true)
27
27
  end
@@ -29,11 +29,24 @@ class RecaptchaClientHelperTest < Test::Unit::TestCase
29
29
  def test_recaptcha_tags_without_noscript
30
30
  assert_no_match /noscript/, recaptcha_tags(:noscript => false)
31
31
  end
32
-
32
+
33
33
  def test_should_raise_exception_without_public_key
34
34
  assert_raise RecaptchaError do
35
35
  Recaptcha.configuration.public_key = nil
36
36
  recaptcha_tags
37
37
  end
38
38
  end
39
+
40
+ def test_different_configuration_within_with_configuration_block
41
+ key = Recaptcha.with_configuration(:public_key => '12345') do
42
+ Recaptcha.configuration.public_key
43
+ end
44
+
45
+ assert_equal('12345', key)
46
+ end
47
+
48
+ def test_reset_configuration_after_with_configuration_block
49
+ Recaptcha.with_configuration(:public_key => '12345')
50
+ assert_equal('0000000000000000000000000000000000000000', Recaptcha.configuration.public_key)
51
+ end
39
52
  end
@@ -1,7 +1,10 @@
1
+ # coding: utf-8
2
+
1
3
  require 'test/unit'
2
- require 'active_support/core_ext/string'
3
4
  require 'rubygems'
5
+ require 'active_support/core_ext/string'
4
6
  require 'mocha'
7
+ require 'i18n'
5
8
  require 'net/http'
6
9
  require File.dirname(File.expand_path(__FILE__)) + '/../lib/recaptcha'
7
10
 
@@ -17,7 +20,7 @@ class RecaptchaVerifyTest < Test::Unit::TestCase
17
20
  @expected_post_data["remoteip"] = @controller.request.remote_ip
18
21
  @expected_post_data["challenge"] = "challenge"
19
22
  @expected_post_data["response"] = "response"
20
-
23
+
21
24
  @expected_uri = URI.parse(Recaptcha.configuration.verify_url)
22
25
  end
23
26
 
@@ -31,24 +34,24 @@ class RecaptchaVerifyTest < Test::Unit::TestCase
31
34
  def test_should_return_false_when_key_is_invalid
32
35
  expect_http_post(response_with_body("false\ninvalid-site-private-key"))
33
36
 
34
- assert !@controller.verify_recaptcha
37
+ assert !@controller.verify_recaptcha
35
38
  assert_equal "invalid-site-private-key", @controller.flash[:recaptcha_error]
36
39
  end
37
-
40
+
38
41
  def test_returns_true_on_success
39
- @controller.flash[:recaptcha_error] = "previous error that should be cleared"
42
+ @controller.flash[:recaptcha_error] = "previous error that should be cleared"
40
43
  expect_http_post(response_with_body("true\n"))
41
44
 
42
45
  assert @controller.verify_recaptcha
43
46
  assert_nil @controller.flash[:recaptcha_error]
44
47
  end
45
-
48
+
46
49
  def test_errors_should_be_added_to_model
47
50
  expect_http_post(response_with_body("false\nbad-news"))
48
-
51
+
49
52
  errors = mock
50
53
  errors.expects(:add).with(:base, "Word verification response is incorrect, please try again.")
51
- model = mock(:valid? => false, :errors => errors)
54
+ model = mock(:errors => errors)
52
55
 
53
56
  assert !@controller.verify_recaptcha(:model => model)
54
57
  assert_equal "bad-news", @controller.flash[:recaptcha_error]
@@ -70,17 +73,39 @@ class RecaptchaVerifyTest < Test::Unit::TestCase
70
73
  assert_equal "recaptcha-not-reachable", @controller.flash[:recaptcha_error]
71
74
  end
72
75
 
76
+ def test_message_should_use_i18n
77
+ I18n.locale = :de
78
+ verification_failed_translated = "Sicherheitscode konnte nicht verifiziert werden."
79
+ verification_failed_default = "Word verification response is incorrect, please try again."
80
+ recaptcha_unreachable_translated = "Netzwerkfehler, bitte versuchen Sie es später erneut."
81
+ recaptcha_unreachable_default = "Oops, we failed to validate your word verification response. Please try again."
82
+ I18n.expects(:translate).with(:'recaptcha.errors.verification_failed', :default => verification_failed_default).returns(verification_failed_translated)
83
+ I18n.expects(:translate).with(:'recaptcha.errors.recaptcha_unreachable', :default => recaptcha_unreachable_default).returns(recaptcha_unreachable_translated)
84
+
85
+ errors = mock
86
+ errors.expects(:add).with(:base, verification_failed_translated)
87
+ errors.expects(:add).with(:base, recaptcha_unreachable_translated)
88
+ model = mock; model.stubs(:errors => errors)
89
+
90
+ expect_http_post(response_with_body("false\nbad-news"))
91
+ @controller.verify_recaptcha(:model => model)
92
+
93
+ expect_http_post(Timeout::Error, :exception => true)
94
+ @controller.verify_recaptcha(:model => model)
95
+
96
+ end
97
+
73
98
  private
74
99
 
75
100
  class TestController
76
101
  include Recaptcha::Verify
77
102
  attr_accessor :request, :params, :flash
78
-
103
+
79
104
  def initialize
80
105
  @flash = {}
81
106
  end
82
107
  end
83
-
108
+
84
109
  def expect_http_post(response, options = {})
85
110
  unless options[:exception]
86
111
  Net::HTTP.expects(:post_form).with(@expected_uri, @expected_post_data).returns(response)
@@ -88,7 +113,7 @@ class RecaptchaVerifyTest < Test::Unit::TestCase
88
113
  Net::HTTP.expects(:post_form).raises response
89
114
  end
90
115
  end
91
-
116
+
92
117
  def response_with_body(body)
93
118
  stub(:body => body)
94
119
  end
metadata CHANGED
@@ -1,59 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 1
9
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - Jason L. Perry
7
+ authors:
8
+ - Jason L Perry
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-12-20 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: mocha
16
+ requirement: &70162456439800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: *70162456439800
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70162456438320 !ruby/object:Gem::Requirement
24
28
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
31
33
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
+ prerelease: false
35
+ version_requirements: *70162456438320
36
+ - !ruby/object:Gem::Dependency
34
37
  name: activesupport
38
+ requirement: &70162456437340 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
35
45
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
46
+ version_requirements: *70162456437340
47
+ - !ruby/object:Gem::Dependency
48
+ name: i18n
49
+ requirement: &70162456435080 !ruby/object:Gem::Requirement
37
50
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
44
55
  type: :development
45
- version_requirements: *id002
46
- description: "This plugin adds helpers for the reCAPTCHA API "
47
- email: jasper@ambethia.com
56
+ prerelease: false
57
+ version_requirements: *70162456435080
58
+ description: This plugin adds helpers for the reCAPTCHA API
59
+ email:
60
+ - jasper@ambethia.com
48
61
  executables: []
49
-
50
62
  extensions: []
51
-
52
- extra_rdoc_files:
53
- - LICENSE
54
- - README.rdoc
55
- files:
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
56
66
  - CHANGELOG
67
+ - Gemfile
68
+ - Gemfile.lock
57
69
  - LICENSE
58
70
  - README.rdoc
59
71
  - Rakefile
@@ -64,43 +76,42 @@ files:
64
76
  - lib/recaptcha/configuration.rb
65
77
  - lib/recaptcha/merb.rb
66
78
  - lib/recaptcha/rails.rb
79
+ - lib/recaptcha/railtie.rb
67
80
  - lib/recaptcha/verify.rb
81
+ - lib/recaptcha/version.rb
68
82
  - recaptcha.gemspec
69
- - tasks/recaptcha_tasks.rake
70
83
  - test/recaptcha_test.rb
71
84
  - test/verify_recaptcha_test.rb
72
- has_rdoc: true
73
- homepage: http://ambethia.com/recaptcha
85
+ homepage: http://github.com/ambethia/recaptcha
74
86
  licenses: []
75
-
76
87
  post_install_message:
77
88
  rdoc_options: []
78
-
79
- require_paths:
89
+ require_paths:
80
90
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
91
+ required_ruby_version: !ruby/object:Gem::Requirement
82
92
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- segments:
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ segments:
87
98
  - 0
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ hash: -241857000290141400
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
101
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- segments:
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ segments:
95
107
  - 0
96
- version: "0"
108
+ hash: -241857000290141400
97
109
  requirements: []
98
-
99
- rubyforge_project:
100
- rubygems_version: 1.3.7
110
+ rubyforge_project: recaptcha
111
+ rubygems_version: 1.8.11
101
112
  signing_key:
102
113
  specification_version: 3
103
114
  summary: Helpers for the reCAPTCHA API
104
- test_files:
115
+ test_files:
105
116
  - test/recaptcha_test.rb
106
117
  - test/verify_recaptcha_test.rb
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :recaptcha do
3
- # # Task goes here
4
- # end