mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
f1d6a0e4d2
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8229 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
35 lines
1,018 B
Ruby
35 lines
1,018 B
Ruby
require 'test/unit'
|
|
|
|
# Must set before requiring generator libs.
|
|
if defined?(RAILS_ROOT)
|
|
RAILS_ROOT.replace "#{File.dirname(__FILE__)}/fixtures"
|
|
else
|
|
RAILS_ROOT = "#{File.dirname(__FILE__)}/fixtures"
|
|
end
|
|
|
|
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
|
|
|
require 'rails_generator'
|
|
require 'rails_generator/secret_key_generator'
|
|
require 'rails_generator/generators/applications/app/app_generator'
|
|
|
|
class SecretKeyGenerationTest < Test::Unit::TestCase
|
|
SECRET_KEY_MIN_LENGTH = 128
|
|
APP_NAME = "foo"
|
|
|
|
def setup
|
|
@generator = Rails::SecretKeyGenerator.new(APP_NAME)
|
|
end
|
|
|
|
def test_secret_key_generation
|
|
assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH
|
|
end
|
|
|
|
Rails::SecretKeyGenerator::GENERATORS.each do |generator|
|
|
if Rails::SecretKeyGenerator.send("supports_#{generator}?")
|
|
define_method("test_secret_key_generation_with_#{generator}") do
|
|
assert @generator.send("generate_secret_with_#{generator}").length >= SECRET_KEY_MIN_LENGTH
|
|
end
|
|
end
|
|
end
|
|
end
|