forked from phatworx/easy_captcha
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Dreher
committed
Sep 8, 2015
1 parent
1f9be89
commit cba14da
Showing
4 changed files
with
69 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,6 @@ PLATFORMS | |
|
||
DEPENDENCIES | ||
easy_captcha! | ||
|
||
BUNDLED WITH | ||
1.10.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
task default: :spec | ||
|
||
require 'yard' | ||
YARD::Rake::YardocTask.new | ||
YARD::Rake::YardocTask.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,114 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe EasyCaptcha do | ||
|
||
describe :setup do | ||
EasyCaptcha.setup do |config| | ||
# Cache | ||
config.cache = false | ||
config.cache = false | ||
|
||
# Chars | ||
config.chars = %w(2 3 4 5 6 7 9 A C D E F G H J K L M N P Q R S T U X Y Z) | ||
config.chars = %w(2 3 4 5 6 7 9 A C D E F G H J K L M N P Q R S T U X Y Z) | ||
|
||
# Length | ||
config.length = 6 | ||
config.length = 6 | ||
|
||
# Image | ||
config.image_height = 40 | ||
config.image_width = 140 | ||
config.image_width = 140 | ||
|
||
# configure generator | ||
config.generator :default do |generator| | ||
|
||
# Font | ||
generator.font_size = 24 | ||
generator.font_fill_color = '#333333' | ||
generator.font_stroke_color = '#000000' | ||
generator.font_stroke = 0 | ||
generator.font_family = File.expand_path('../../resources/afont.ttf', __FILE__) | ||
generator.font_size = 24 | ||
generator.font_fill_color = '#333333' | ||
generator.font_stroke_color = '#000000' | ||
generator.font_stroke = 0 | ||
generator.font_family = File.expand_path('../../resources/afont.ttf', __FILE__) | ||
|
||
generator.image_background_color = "#FFFFFF" | ||
generator.image_background_color = '#FFFFFF' | ||
|
||
# Wave | ||
generator.wave = true | ||
generator.wave_length = (60..100) | ||
generator.wave_amplitude = (3..5) | ||
generator.wave = true | ||
generator.wave_length = (60..100) | ||
generator.wave_amplitude = (3..5) | ||
|
||
# Sketch | ||
generator.sketch = true | ||
generator.sketch_radius = 3 | ||
generator.sketch_sigma = 1 | ||
generator.sketch = true | ||
generator.sketch_radius = 3 | ||
generator.sketch_sigma = 1 | ||
|
||
# Implode | ||
generator.implode = 0.1 | ||
generator.implode = 0.1 | ||
|
||
# Blur | ||
generator.blur = true | ||
generator.blur_radius = 1 | ||
generator.blur_sigma = 2 | ||
generator.blur = true | ||
generator.blur_radius = 1 | ||
generator.blur_sigma = 2 | ||
end | ||
end | ||
|
||
it "sould not cache" do | ||
it 'sould not cache' do | ||
EasyCaptcha.cache?.should be_false | ||
end | ||
|
||
it "should have default generator" do | ||
it 'should have default generator' do | ||
EasyCaptcha.generator.should be_an(EasyCaptcha::Generator::Default) | ||
end | ||
|
||
describe :depracations do | ||
before do | ||
EasyCaptcha.setup do |config| | ||
# Length | ||
config.length = 6 | ||
config.length = 6 | ||
|
||
# Image | ||
config.image_height = 40 | ||
config.image_width = 140 | ||
|
||
# Font | ||
config.font_size = 24 | ||
config.font_fill_color = '#333333' | ||
config.font_stroke_color = '#000000' | ||
config.font_stroke = 0 | ||
config.font_family = File.expand_path('../../resources/afont.ttf', __FILE__) | ||
|
||
config.image_background_color = "#FFFFFF" | ||
|
||
# Wave | ||
config.wave = true | ||
config.wave_length = (60..100) | ||
config.wave_amplitude = (3..5) | ||
|
||
# Sketch | ||
config.sketch = true | ||
config.sketch_radius = 3 | ||
config.sketch_sigma = 1 | ||
|
||
# Implode | ||
config.implode = 0.1 | ||
|
||
# Blur | ||
config.blur = true | ||
config.blur_radius = 1 | ||
config.blur_sigma = 2 | ||
config.image_height = 40 | ||
config.image_width = 140 | ||
|
||
config.generator :default do |generator| | ||
# Font | ||
generator.font_size = 24 | ||
generator.font_fill_color = '#333333' | ||
generator.font_stroke_color = '#000000' | ||
generator.font_stroke = 0 | ||
generator.font_family = File.expand_path('../../resources/afont.ttf', __FILE__) | ||
|
||
generator.image_background_color = '#FFFFFF' | ||
|
||
# Wave | ||
generator.wave = true | ||
generator.wave_length = (60..100) | ||
generator.wave_amplitude = (3..5) | ||
|
||
# Sketch | ||
generator.sketch = true | ||
generator.sketch_radius = 3 | ||
generator.sketch_sigma = 1 | ||
|
||
# Implode | ||
generator.implode = 0.1 | ||
|
||
# Blur | ||
generator.blur = true | ||
generator.blur_radius = 1 | ||
generator.blur_sigma = 2 | ||
end | ||
end | ||
end | ||
|
||
it "get config" do | ||
it 'get config' do | ||
[ | ||
:font_size, :font_fill_color, :font_family, :font_stroke, :font_stroke_color, | ||
:image_background_color, :sketch, :sketch_radius, :sketch_sigma, :wave, | ||
:wave_length, :wave_amplitude, :implode, :blur, :blur_radius, :blur_sigma | ||
:font_size, :font_fill_color, :font_family, :font_stroke, :font_stroke_color, | ||
:image_background_color, :sketch, :sketch_radius, :sketch_sigma, :wave, | ||
:wave_length, :wave_amplitude, :implode, :blur, :blur_radius, :blur_sigma | ||
].each do |method| | ||
EasyCaptcha.send("#{method}").should_not be_nil | ||
EasyCaptcha.generator.send(method).should_not be_nil | ||
end | ||
end | ||
|
||
it "method_missing should call normal on non depracations" do | ||
lambda { EasyCaptcha.send("a_missing_method") }.should raise_error | ||
it 'method_missing should call normal on non depracations' do | ||
-> { EasyCaptcha.send('a_missing_method') }.should raise_error | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters