Skip to content

Commit

Permalink
fixes rspec and rake
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Dreher committed Sep 8, 2015
1 parent 1f9be89 commit cba14da
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 71 deletions.
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ PLATFORMS

DEPENDENCIES
easy_captcha!

BUNDLED WITH
1.10.3
8 changes: 5 additions & 3 deletions Rakefile
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
124 changes: 61 additions & 63 deletions spec/easy_captcha_spec.rb
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
5 changes: 0 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
SimpleCov.start 'rails'
rescue LoadError
end
require 'rspec'
require 'easy_captcha'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

RSpec.configure do |config|

end

0 comments on commit cba14da

Please sign in to comment.