makers 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +149 -0
- data/Rakefile +32 -0
- data/lib/generators/makers/model/model_generator.rb +15 -0
- data/lib/generators/makers/model/templates/maker.rb +2 -0
- data/lib/makers.rb +57 -0
- data/lib/makers/callbacks.rb +23 -0
- data/lib/makers/configuration.rb +10 -0
- data/lib/makers/definitions.rb +43 -0
- data/lib/makers/fetcher.rb +18 -0
- data/lib/makers/maker.rb +113 -0
- data/lib/makers/methods.rb +11 -0
- data/lib/makers/proxy.rb +52 -0
- data/lib/makers/railtie.rb +33 -0
- data/lib/makers/sequence.rb +19 -0
- data/lib/makers/version.rb +5 -0
- data/test/aliases_test.rb +20 -0
- data/test/associations_test.rb +50 -0
- data/test/attributes_test.rb +26 -0
- data/test/callbacks_test.rb +38 -0
- data/test/clean_test.rb +18 -0
- data/test/dependent_test.rb +30 -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 +87 -0
- data/test/dummy/config/environments/test.rb +47 -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 +13 -0
- data/test/dummy/db/migrate/20140615180954_create_posts.rb +10 -0
- data/test/dummy/db/schema.rb +33 -0
- data/test/dummy/log/test.log +273 -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/makers/people.rb +2 -0
- data/test/dummy/test/makers/users.rb +3 -0
- data/test/fabricators_test.rb +33 -0
- data/test/generators_test.rb +13 -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 +26 -0
- metadata +202 -0
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MakersTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Makers.define do
|
7
|
+
maker :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/makers/model/model_generator'
|
4
|
+
|
5
|
+
class GeneratorsTest < Rails::Generators::TestCase
|
6
|
+
tests Makers::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,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InheritanceTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Makers.define do
|
7
|
+
maker :user do
|
8
|
+
name 'name'
|
9
|
+
maker :user_with_age do
|
10
|
+
age 9
|
11
|
+
end
|
12
|
+
end
|
13
|
+
maker :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
|
+
Makers.define do
|
7
|
+
maker :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
|
+
Makers.define do
|
7
|
+
maker :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,26 @@
|
|
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
|
+
setup { Makers.reset }
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: makers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Museways
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.3.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
description: Minimalistic factory inspired in factory_girl for rails.
|
48
|
+
email:
|
49
|
+
- hello@museways.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- MIT-LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/generators/makers/model/model_generator.rb
|
58
|
+
- lib/generators/makers/model/templates/maker.rb
|
59
|
+
- lib/makers.rb
|
60
|
+
- lib/makers/callbacks.rb
|
61
|
+
- lib/makers/configuration.rb
|
62
|
+
- lib/makers/definitions.rb
|
63
|
+
- lib/makers/fetcher.rb
|
64
|
+
- lib/makers/maker.rb
|
65
|
+
- lib/makers/methods.rb
|
66
|
+
- lib/makers/proxy.rb
|
67
|
+
- lib/makers/railtie.rb
|
68
|
+
- lib/makers/sequence.rb
|
69
|
+
- lib/makers/version.rb
|
70
|
+
- test/aliases_test.rb
|
71
|
+
- test/associations_test.rb
|
72
|
+
- test/attributes_test.rb
|
73
|
+
- test/callbacks_test.rb
|
74
|
+
- test/clean_test.rb
|
75
|
+
- test/dependent_test.rb
|
76
|
+
- test/dummy/README.rdoc
|
77
|
+
- test/dummy/Rakefile
|
78
|
+
- test/dummy/app/assets/javascripts/application.js
|
79
|
+
- test/dummy/app/assets/stylesheets/application.css
|
80
|
+
- test/dummy/app/controllers/application_controller.rb
|
81
|
+
- test/dummy/app/helpers/application_helper.rb
|
82
|
+
- test/dummy/app/models/group.rb
|
83
|
+
- test/dummy/app/models/post.rb
|
84
|
+
- test/dummy/app/models/user.rb
|
85
|
+
- test/dummy/app/views/layouts/application.html.erb
|
86
|
+
- test/dummy/bin/bundle
|
87
|
+
- test/dummy/bin/rails
|
88
|
+
- test/dummy/bin/rake
|
89
|
+
- test/dummy/config.ru
|
90
|
+
- test/dummy/config/application.rb
|
91
|
+
- test/dummy/config/boot.rb
|
92
|
+
- test/dummy/config/database.yml
|
93
|
+
- test/dummy/config/environment.rb
|
94
|
+
- test/dummy/config/environments/development.rb
|
95
|
+
- test/dummy/config/environments/production.rb
|
96
|
+
- test/dummy/config/environments/test.rb
|
97
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
98
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
99
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
100
|
+
- test/dummy/config/initializers/inflections.rb
|
101
|
+
- test/dummy/config/initializers/mime_types.rb
|
102
|
+
- test/dummy/config/initializers/session_store.rb
|
103
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
104
|
+
- test/dummy/config/locales/en.yml
|
105
|
+
- test/dummy/config/routes.rb
|
106
|
+
- test/dummy/config/secrets.yml
|
107
|
+
- test/dummy/db/migrate/20140613221835_create_users.rb
|
108
|
+
- test/dummy/db/migrate/20140615180954_create_posts.rb
|
109
|
+
- test/dummy/db/schema.rb
|
110
|
+
- test/dummy/log/test.log
|
111
|
+
- test/dummy/public/404.html
|
112
|
+
- test/dummy/public/422.html
|
113
|
+
- test/dummy/public/500.html
|
114
|
+
- test/dummy/public/favicon.ico
|
115
|
+
- test/dummy/test/makers/people.rb
|
116
|
+
- test/dummy/test/makers/users.rb
|
117
|
+
- test/fabricators_test.rb
|
118
|
+
- test/generators_test.rb
|
119
|
+
- test/inheritance_test.rb
|
120
|
+
- test/lists_test.rb
|
121
|
+
- test/load_test.rb
|
122
|
+
- test/merges_test.rb
|
123
|
+
- test/test_helper.rb
|
124
|
+
homepage: https://github.com/museways/makers
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.9.3
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.5
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Makers for Rails
|
148
|
+
test_files:
|
149
|
+
- test/aliases_test.rb
|
150
|
+
- test/associations_test.rb
|
151
|
+
- test/attributes_test.rb
|
152
|
+
- test/callbacks_test.rb
|
153
|
+
- test/clean_test.rb
|
154
|
+
- test/dependent_test.rb
|
155
|
+
- test/dummy/app/assets/javascripts/application.js
|
156
|
+
- test/dummy/app/assets/stylesheets/application.css
|
157
|
+
- test/dummy/app/controllers/application_controller.rb
|
158
|
+
- test/dummy/app/helpers/application_helper.rb
|
159
|
+
- test/dummy/app/models/group.rb
|
160
|
+
- test/dummy/app/models/post.rb
|
161
|
+
- test/dummy/app/models/user.rb
|
162
|
+
- test/dummy/app/views/layouts/application.html.erb
|
163
|
+
- test/dummy/bin/bundle
|
164
|
+
- test/dummy/bin/rails
|
165
|
+
- test/dummy/bin/rake
|
166
|
+
- test/dummy/config/application.rb
|
167
|
+
- test/dummy/config/boot.rb
|
168
|
+
- test/dummy/config/database.yml
|
169
|
+
- test/dummy/config/environment.rb
|
170
|
+
- test/dummy/config/environments/development.rb
|
171
|
+
- test/dummy/config/environments/production.rb
|
172
|
+
- test/dummy/config/environments/test.rb
|
173
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
174
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
175
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
176
|
+
- test/dummy/config/initializers/inflections.rb
|
177
|
+
- test/dummy/config/initializers/mime_types.rb
|
178
|
+
- test/dummy/config/initializers/session_store.rb
|
179
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
180
|
+
- test/dummy/config/locales/en.yml
|
181
|
+
- test/dummy/config/routes.rb
|
182
|
+
- test/dummy/config/secrets.yml
|
183
|
+
- test/dummy/config.ru
|
184
|
+
- test/dummy/db/migrate/20140613221835_create_users.rb
|
185
|
+
- test/dummy/db/migrate/20140615180954_create_posts.rb
|
186
|
+
- test/dummy/db/schema.rb
|
187
|
+
- test/dummy/log/test.log
|
188
|
+
- test/dummy/public/404.html
|
189
|
+
- test/dummy/public/422.html
|
190
|
+
- test/dummy/public/500.html
|
191
|
+
- test/dummy/public/favicon.ico
|
192
|
+
- test/dummy/Rakefile
|
193
|
+
- test/dummy/README.rdoc
|
194
|
+
- test/dummy/test/makers/people.rb
|
195
|
+
- test/dummy/test/makers/users.rb
|
196
|
+
- test/fabricators_test.rb
|
197
|
+
- test/generators_test.rb
|
198
|
+
- test/inheritance_test.rb
|
199
|
+
- test/lists_test.rb
|
200
|
+
- test/load_test.rb
|
201
|
+
- test/merges_test.rb
|
202
|
+
- test/test_helper.rb
|