fabricators 0.0.1
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +134 -0
- data/Rakefile +32 -0
- data/lib/fabricators.rb +41 -0
- data/lib/fabricators/callbacks.rb +23 -0
- data/lib/fabricators/definitions.rb +58 -0
- data/lib/fabricators/fabricator.rb +102 -0
- data/lib/fabricators/generator.rb +19 -0
- data/lib/fabricators/methods.rb +11 -0
- data/lib/fabricators/proxy.rb +45 -0
- data/lib/fabricators/railtie.rb +14 -0
- data/lib/fabricators/reader.rb +18 -0
- data/lib/fabricators/version.rb +5 -0
- data/lib/generators/fabricators/model/model_generator.rb +15 -0
- data/lib/generators/fabricators/model/templates/fabricator.rb +4 -0
- data/test/aliases_test.rb +25 -0
- data/test/associations_test.rb +50 -0
- data/test/callbacks_test.rb +36 -0
- data/test/dependent_test.rb +26 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/group.rb +2 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +22 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +83 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20140613221835_create_users.rb +10 -0
- data/test/dummy/db/migrate/20140615152257_add_age_to_users.rb +5 -0
- data/test/dummy/db/migrate/20140615175509_add_phone_to_users.rb +5 -0
- data/test/dummy/db/migrate/20140615180938_create_groups.rb +9 -0
- data/test/dummy/db/migrate/20140615180954_create_posts.rb +9 -0
- data/test/dummy/db/migrate/20140615181030_add_group_id_to_users.rb +5 -0
- data/test/dummy/db/migrate/20140615181051_add_user_id_to_posts.rb +5 -0
- data/test/dummy/db/schema.rb +39 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +14513 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fabricators/people.rb +4 -0
- data/test/dummy/test/fabricators/users.rb +5 -0
- data/test/fabricators_test.rb +33 -0
- data/test/fixtures_test.rb +13 -0
- data/test/generators_test.rb +36 -0
- data/test/inheritance_test.rb +49 -0
- data/test/lists_test.rb +33 -0
- data/test/load_test.rb +13 -0
- data/test/merges_test.rb +31 -0
- data/test/test_helper.rb +27 -0
- metadata +211 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FabricatorsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Fabricators.define do
|
7
|
+
fabricator :user do
|
8
|
+
name 'name'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
test "return attributes" do
|
14
|
+
hash = attributes_for(:user)
|
15
|
+
assert_kind_of Hash, hash
|
16
|
+
assert_equal 'name', hash[:name]
|
17
|
+
end
|
18
|
+
|
19
|
+
test "build instance" do
|
20
|
+
record = build(:user)
|
21
|
+
assert_kind_of User, record
|
22
|
+
assert record.new_record?
|
23
|
+
assert_equal 'name', record.name
|
24
|
+
end
|
25
|
+
|
26
|
+
test "create instance" do
|
27
|
+
record = create(:user)
|
28
|
+
assert_kind_of User, record
|
29
|
+
assert record.persisted?
|
30
|
+
assert_equal 'name', record.name
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'generators/fabricators/model/model_generator'
|
4
|
+
|
5
|
+
class FixturesTest < Rails::Generators::TestCase
|
6
|
+
tests Fabricators::Generators::ModelGenerator
|
7
|
+
destination File.expand_path('../tmp', File.dirname(__FILE__))
|
8
|
+
|
9
|
+
test "file generation" do
|
10
|
+
run_generator %w(person)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GeneratorsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Fabricators.define do
|
7
|
+
generator(:name) { 'name' }
|
8
|
+
generator(:email) { |n| "mail#{n}@example.com" }
|
9
|
+
generator(:age)
|
10
|
+
fabricator :user do
|
11
|
+
name
|
12
|
+
age
|
13
|
+
email
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
test "static generator" do
|
19
|
+
assert_equal 'name', attributes_for(:user)[:name]
|
20
|
+
assert_equal 'name', build(:user).name
|
21
|
+
assert_equal 'name', create(:user).name
|
22
|
+
end
|
23
|
+
|
24
|
+
test "block generator" do
|
25
|
+
assert_equal 'mail1@example.com', attributes_for(:user)[:email]
|
26
|
+
assert_equal 'mail2@example.com', build(:user).email
|
27
|
+
assert_equal 'mail3@example.com', create(:user).email
|
28
|
+
end
|
29
|
+
|
30
|
+
test "number generator" do
|
31
|
+
assert_equal 1, attributes_for(:user)[:age]
|
32
|
+
assert_equal 2, build(:user).age
|
33
|
+
assert_equal 3, create(:user).age
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InheritanceTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Fabricators.define do
|
7
|
+
fabricator :user do
|
8
|
+
name 'name'
|
9
|
+
fabricator :user_with_age do
|
10
|
+
age 9
|
11
|
+
end
|
12
|
+
end
|
13
|
+
fabricator :user_with_email, parent: :user do
|
14
|
+
email 'mail@example.com'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
test "return attributes" do
|
20
|
+
user_with_age = attributes_for(:user_with_age)
|
21
|
+
assert_equal 'name', user_with_age[:name]
|
22
|
+
assert_equal 9, user_with_age[:age]
|
23
|
+
|
24
|
+
user_with_email = attributes_for(:user_with_email)
|
25
|
+
assert_equal 'name', user_with_email[:name]
|
26
|
+
assert_equal 'mail@example.com', user_with_email[:email]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "build instance" do
|
30
|
+
user_with_age = build(:user_with_age)
|
31
|
+
assert_equal 'name', user_with_age.name
|
32
|
+
assert_equal 9, user_with_age.age
|
33
|
+
|
34
|
+
user_with_email = build(:user_with_email)
|
35
|
+
assert_equal 'name', user_with_email.name
|
36
|
+
assert_equal 'mail@example.com', user_with_email.email
|
37
|
+
end
|
38
|
+
|
39
|
+
test "create instance" do
|
40
|
+
user_with_age = create(:user_with_age)
|
41
|
+
assert_equal 'name', user_with_age.name
|
42
|
+
assert_equal 9, user_with_age.age
|
43
|
+
|
44
|
+
user_with_email = create(:user_with_email)
|
45
|
+
assert_equal 'name', user_with_email.name
|
46
|
+
assert_equal 'mail@example.com', user_with_email.email
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/test/lists_test.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Fabricators.define do
|
7
|
+
fabricator :user do
|
8
|
+
name 'name'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
test "build list" do
|
14
|
+
list = build(:user, 3)
|
15
|
+
assert_equal 3, list.size
|
16
|
+
list.each do |user|
|
17
|
+
assert_kind_of User, user
|
18
|
+
assert user.new_record?
|
19
|
+
assert_equal 'name', user.name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
test "create list" do
|
24
|
+
list = create(:user, 3)
|
25
|
+
assert_equal 3, list.size
|
26
|
+
list.each do |user|
|
27
|
+
assert_kind_of User, user
|
28
|
+
assert user.persisted?
|
29
|
+
assert_equal 'name', user.name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/test/load_test.rb
ADDED
data/test/merges_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MergesTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Fabricators.define do
|
7
|
+
fabricator :user do
|
8
|
+
name 'name'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
test "return attributes" do
|
14
|
+
assert_equal 'other', attributes_for(:user, name: 'other')[:name]
|
15
|
+
end
|
16
|
+
|
17
|
+
test "build instance" do
|
18
|
+
assert_equal 'other', build(:user, name: 'other').name
|
19
|
+
build(:user, 3, name: 'other').each do |user|
|
20
|
+
assert_equal 'other', user.name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
test "create instance" do
|
25
|
+
assert_equal 'other', create(:user, name: 'other').name
|
26
|
+
create(:user, 3, name: 'other').each do |user|
|
27
|
+
assert_equal 'other', user.name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
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 }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Load database
|
18
|
+
config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
|
19
|
+
config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
|
20
|
+
ActiveRecord::Base.establish_connection(config['test'])
|
21
|
+
load(File.expand_path('../dummy/db/schema.rb', __FILE__))
|
22
|
+
|
23
|
+
# Include methods
|
24
|
+
class ActiveSupport::TestCase
|
25
|
+
include Fabricators::Methods
|
26
|
+
setup { Fabricators.definitions.reset! }
|
27
|
+
end
|