randomized_field 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/.rspec +3 -0
- data/.rubocop.yml +24 -0
- data/.travis.yml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -68
- data/Rakefile +4 -35
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/randomized_field.rb +18 -4
- data/lib/randomized_field/callback.rb +30 -0
- data/lib/randomized_field/generator.rb +23 -0
- data/lib/randomized_field/version.rb +1 -2
- data/randomized_field.gemspec +49 -0
- metadata +133 -144
- data/MIT-LICENSE +0 -20
- data/lib/randomized_field/base.rb +0 -21
- data/lib/randomized_field/defaults.rb +0 -8
- data/lib/randomized_field/randomizer.rb +0 -31
- data/lib/tasks/randomized_field_tasks.rake +0 -4
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -9
- data/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/default_model.rb +0 -3
- data/test/dummy/app/models/prefix_model.rb +0 -3
- data/test/dummy/app/models/single_character_model.rb +0 -3
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -45
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -30
- data/test/dummy/config/environments/production.rb +0 -60
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20120204224641_create_default_models.rb +0 -9
- data/test/dummy/db/migrate/20120204235832_create_prefix_models.rb +0 -9
- data/test/dummy/db/migrate/20120205000853_create_single_character_models.rb +0 -9
- data/test/dummy/db/schema.rb +0 -34
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -269
- data/test/dummy/log/test.log +0 -1186
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/fixtures/default_models.yml +0 -7
- data/test/dummy/test/fixtures/prefix_models.yml +0 -7
- data/test/dummy/test/fixtures/simple_models.yml +0 -7
- data/test/dummy/test/fixtures/single_character_models.yml +0 -7
- data/test/dummy/test/unit/default_model_test.rb +0 -7
- data/test/dummy/test/unit/prefix_model_test.rb +0 -7
- data/test/dummy/test/unit/single_character_model_test.rb +0 -7
- data/test/randomized_field_test.rb +0 -69
- data/test/test_helper.rb +0 -10
data/test/dummy/public/404.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/404.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
File without changes
|
data/test/dummy/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RandomizedFieldTest < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@models = {
|
6
|
-
:default_model => DefaultModel.create,
|
7
|
-
:prefix_model => PrefixModel.create,
|
8
|
-
:single_character_model => SingleCharacterModel.create
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
@models.each { |(model_name, model)| model.destroy }
|
14
|
-
end
|
15
|
-
|
16
|
-
test "truth" do
|
17
|
-
assert_kind_of Module, RandomizedField
|
18
|
-
assert_kind_of Module, RandomizedField::Base
|
19
|
-
assert_kind_of Class, RandomizedField::Randomizer
|
20
|
-
end
|
21
|
-
|
22
|
-
test "DefaultModel should have the default randomized field options set" do
|
23
|
-
model = @models[:default_model]
|
24
|
-
|
25
|
-
field_name = model.class.randomized_field_name
|
26
|
-
options = model.class.randomized_field_options
|
27
|
-
|
28
|
-
assert_equal options[:prefix], RandomizedField::DEFAULTS[:prefix]
|
29
|
-
assert_equal options[:length], RandomizedField::DEFAULTS[:length]
|
30
|
-
assert_equal options[:valid_characters], RandomizedField::DEFAULTS[:valid_characters]
|
31
|
-
end
|
32
|
-
|
33
|
-
test "The instance of DefaultModel should have the default random field values set" do
|
34
|
-
model = @models[:default_model]
|
35
|
-
|
36
|
-
field_name = model.class.randomized_field_name
|
37
|
-
|
38
|
-
assert_respond_to model, field_name
|
39
|
-
assert model[field_name].present?
|
40
|
-
assert_equal model[field_name].length, RandomizedField::DEFAULTS[:length]
|
41
|
-
|
42
|
-
assert_match /^#{RandomizedField::DEFAULTS[:prefix]}[#{RandomizedField::DEFAULTS[:valid_characters].join("|")}]+$/,
|
43
|
-
model[field_name]
|
44
|
-
end
|
45
|
-
|
46
|
-
test "PrefixModel should have a randomized field with a prefix" do
|
47
|
-
model = @models[:prefix_model]
|
48
|
-
|
49
|
-
field_name = model.class.randomized_field_name
|
50
|
-
options = model.class.randomized_field_options
|
51
|
-
|
52
|
-
assert_operator options[:prefix].length, :>, 0
|
53
|
-
assert_match /^#{options[:prefix]}/, model[field_name]
|
54
|
-
assert_equal model[field_name].length, options[:prefix].length + options[:length]
|
55
|
-
end
|
56
|
-
|
57
|
-
test "SingleCharacterModel should have a randomized field containing a single character" do
|
58
|
-
model = @models[:single_character_model]
|
59
|
-
|
60
|
-
field_name = model.class.randomized_field_name
|
61
|
-
options = model.class.randomized_field_options
|
62
|
-
|
63
|
-
assert_equal options[:valid_characters].length, 1
|
64
|
-
|
65
|
-
character = options[:valid_characters].first
|
66
|
-
|
67
|
-
assert_equal model[field_name], character*options[:length]
|
68
|
-
end
|
69
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
-
require "rails/test_help"
|
6
|
-
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
8
|
-
|
9
|
-
# Load support files
|
10
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|