aritcaptcha 1.11.0 → 1.12.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.0
1
+ 1.12.0
data/aritcaptcha.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aritcaptcha}
8
- s.version = "1.11.0"
8
+ s.version = "1.12.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Guilherme Nascimento"]
@@ -14,7 +14,11 @@ module Aritcaptcha
14
14
  number2 = options[:two] || 50
15
15
  operation = options[:op] || OPERATIONS[rand(OPERATIONS.size)]
16
16
 
17
- equation, result = Aritcaptcha::Calculation.generate_calculation number1, number2, operation
17
+ result = nil
18
+
19
+ while result.nil? or !result.is_a?(Integer) or result < 0
20
+ equation, result = Aritcaptcha::Calculation.generate_calculation number1, number2, operation
21
+ end
18
22
 
19
23
  session[:equation] = [equation_key, eval(equation)]
20
24
 
@@ -7,6 +7,9 @@ module Aritcaptcha
7
7
  number2 = rand(number2)
8
8
  equation = "#{number1} #{operation} #{number2}"
9
9
 
10
+ # Division by zero
11
+ return [nil, nil] if operation == "/" and number2.zero?
12
+
10
13
  result = eval("#{number1.to_f} #{operation} #{number2.to_f}")
11
14
 
12
15
  [equation, result]
@@ -14,4 +17,6 @@ module Aritcaptcha
14
17
 
15
18
  end
16
19
 
17
- end
20
+ end
21
+
22
+ puts Aritcaptcha::Calculation.generate_calculation(10, 0, "/")
@@ -1,11 +1,11 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "AritcaptchaHelper" do
4
- before :each do
5
- @helper = Captcha::AritcaptchaHelper.new
6
- end
7
-
8
- it "should accept two numbers and the operator as argument" do
9
- puts @helper.aritcaptcha_tag :html => { :one => "10", :two => "10", :operation => "+" }
10
- end
11
- end
1
+ # require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ #
3
+ # describe "AritcaptchaHelper" do
4
+ # before :each do
5
+ # @helper = Aritcaptcha::AritcaptchaHelper
6
+ # end
7
+ #
8
+ # it "should accept two numbers and the operator as argument" do
9
+ # puts Aritcaptcha::AritcaptchaHelper.aritcaptcha_tag :html => { :one => "10", :two => "10", :operation => "+" }
10
+ # end
11
+ # end
@@ -1,19 +1,19 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Aritcaptcha" do
4
- # it "should return the correct sum of its arguments" do
5
- # Captcha::Aritcaptcha.generate_calculation(10, 10, "+").should == ["10 + 10", 20]
6
- # end
7
- #
8
- # it "should return the subtraction of its arguments" do
9
- # Captcha::Aritcaptcha.generate_calculation(20, 10, "-").should == ["20 - 10", 10]
10
- # end
11
- #
12
- # it "should return the division of its arguments" do
13
- # Captcha::Aritcaptcha.generate_calculation(10, 2, "/").should == ["10 / 2", 5]
14
- # end
15
- #
16
- # it "should return the multiplicationof its arguments" do
17
- # Captcha::Aritcaptcha.generate_calculation(10, 10, "*").should == ["10 * 10", 100]
18
- # end
19
- end
1
+ # require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ #
3
+ # describe "Aritcaptcha" do
4
+ # it "should return the correct sum of its arguments" do
5
+ # Aritcaptcha::Calculation.generate_calculation(10, 10, "+").should == ["10 + 10", 20]
6
+ # end
7
+ # #
8
+ # # it "should return the subtraction of its arguments" do
9
+ # # Captcha::Aritcaptcha.generate_calculation(20, 10, "-").should == ["20 - 10", 10]
10
+ # # end
11
+ # #
12
+ # # it "should return the division of its arguments" do
13
+ # # Captcha::Aritcaptcha.generate_calculation(10, 2, "/").should == ["10 / 2", 5]
14
+ # # end
15
+ # #
16
+ # # it "should return the multiplicationof its arguments" do
17
+ # # Captcha::Aritcaptcha.generate_calculation(10, 10, "*").should == ["10 * 10", 100]
18
+ # # end
19
+ # end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'aritcaptcha/calculation'
4
- require 'aritcaptcha_helper'
4
+ require 'aritcaptcha/aritcaptcha_helper'
5
5
  require 'spec'
6
6
  require 'spec/autorun'
7
7
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aritcaptcha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 39
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 11
8
+ - 12
9
9
  - 0
10
- version: 1.11.0
10
+ version: 1.12.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Guilherme Nascimento