seed_builder 1.2.1 → 1.3.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 +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +116 -19
- data/bin/seed +36 -0
- data/lib/seed_builder/config.rb +8 -6
- data/lib/seed_builder/loader.rb +172 -34
- data/lib/seed_builder/railtie.rb +15 -0
- data/lib/seed_builder.rb +22 -2
- data/lib/tasks/seed.rake +22 -0
- data/seed_builder.gemspec +25 -18
- data/sig/seed_builder/config.rbs +22 -0
- data/sig/seed_builder/loader.rbs +8 -0
- data/sig/seed_builder/railtie.rbs +5 -0
- data/sig/seed_builder.rbs +7 -0
- metadata +164 -71
- data/.editorconfig +0 -14
- data/.github/dependabot.yml +0 -27
- data/.github/workflows/_trunk_check.yml +0 -15
- data/.github/workflows/test.yml +0 -42
- data/.gitignore +0 -24
- data/.ruby-version +0 -1
- data/.trunk/.gitignore +0 -9
- data/.trunk/configs/.markdownlint.yaml +0 -2
- data/.trunk/configs/.shellcheckrc +0 -7
- data/.trunk/configs/.yamllint.yaml +0 -7
- data/.trunk/trunk.yaml +0 -39
- data/.vscode/extensions.json +0 -18
- data/.vscode/settings.json +0 -7
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -260
- data/lib/rails_config.rb +0 -3
- data/spec/fixtures/schema.rb +0 -9
- data/spec/fixtures/seeds/20241206200111_create_users.rb +0 -5
- data/spec/fixtures/seeds.rb +0 -1
- data/spec/generator_spec.rb +0 -50
- data/spec/seed_builder/config_spec.rb +0 -33
- data/spec/seed_builder/loader_spec.rb +0 -35
- data/spec/seed_builder_spec.rb +0 -25
- data/spec/spec_helper.rb +0 -23
- data/spec/support/junit_formatter.rb +0 -6
- data/spec/support/rails_helpers.rb +0 -41
- data/usr/bin/release.sh +0 -35
data/.trunk/trunk.yaml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
|
|
2
|
-
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
|
|
3
|
-
version: 0.1
|
|
4
|
-
cli:
|
|
5
|
-
version: 1.22.8
|
|
6
|
-
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
|
|
7
|
-
plugins:
|
|
8
|
-
sources:
|
|
9
|
-
- id: trunk
|
|
10
|
-
ref: v1.6.5
|
|
11
|
-
uri: https://github.com/trunk-io/plugins
|
|
12
|
-
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
|
13
|
-
runtimes:
|
|
14
|
-
enabled:
|
|
15
|
-
- ruby@3.1.4
|
|
16
|
-
- go@1.21.0
|
|
17
|
-
- node@18.12.1
|
|
18
|
-
- python@3.10.8
|
|
19
|
-
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
|
|
20
|
-
lint:
|
|
21
|
-
enabled:
|
|
22
|
-
- standardrb@1.3.0
|
|
23
|
-
- actionlint@1.7.4
|
|
24
|
-
- checkov@3.2.332
|
|
25
|
-
- git-diff-check
|
|
26
|
-
- markdownlint@0.43.0
|
|
27
|
-
- osv-scanner@1.9.1
|
|
28
|
-
- prettier@3.4.2
|
|
29
|
-
- shellcheck@0.10.0
|
|
30
|
-
- shfmt@3.6.0
|
|
31
|
-
- trufflehog@3.85.0
|
|
32
|
-
- yamllint@1.35.1
|
|
33
|
-
actions:
|
|
34
|
-
disabled:
|
|
35
|
-
- trunk-announce
|
|
36
|
-
- trunk-check-pre-push
|
|
37
|
-
- trunk-fmt-pre-commit
|
|
38
|
-
enabled:
|
|
39
|
-
- trunk-upgrade-available
|
data/.vscode/extensions.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"donjayamanne.githistory",
|
|
4
|
-
"editorconfig.editorconfig",
|
|
5
|
-
"mikestead.dotenv",
|
|
6
|
-
"anweber.vscode-httpyac",
|
|
7
|
-
"shopify.ruby-lsp",
|
|
8
|
-
"bung87.vscode-gemfile",
|
|
9
|
-
"wayou.vscode-todo-highlight",
|
|
10
|
-
"vscode-icons-team.vscode-icons",
|
|
11
|
-
"koichisasada.vscode-rdbg",
|
|
12
|
-
"fooo.ruby-spec-runner",
|
|
13
|
-
"nhoizey.gremlins",
|
|
14
|
-
"streetsidesoftware.code-spell-checker",
|
|
15
|
-
"dewski.simplecov",
|
|
16
|
-
"trunk.io"
|
|
17
|
-
]
|
|
18
|
-
}
|
data/.vscode/settings.json
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
seed_builder (1.2.1)
|
|
5
|
-
activerecord (>= 6, < 8.1)
|
|
6
|
-
rails (>= 6, < 8.1)
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: https://rubygems.org/
|
|
10
|
-
specs:
|
|
11
|
-
actioncable (8.0.0)
|
|
12
|
-
actionpack (= 8.0.0)
|
|
13
|
-
activesupport (= 8.0.0)
|
|
14
|
-
nio4r (~> 2.0)
|
|
15
|
-
websocket-driver (>= 0.6.1)
|
|
16
|
-
zeitwerk (~> 2.6)
|
|
17
|
-
actionmailbox (8.0.0)
|
|
18
|
-
actionpack (= 8.0.0)
|
|
19
|
-
activejob (= 8.0.0)
|
|
20
|
-
activerecord (= 8.0.0)
|
|
21
|
-
activestorage (= 8.0.0)
|
|
22
|
-
activesupport (= 8.0.0)
|
|
23
|
-
mail (>= 2.8.0)
|
|
24
|
-
actionmailer (8.0.0)
|
|
25
|
-
actionpack (= 8.0.0)
|
|
26
|
-
actionview (= 8.0.0)
|
|
27
|
-
activejob (= 8.0.0)
|
|
28
|
-
activesupport (= 8.0.0)
|
|
29
|
-
mail (>= 2.8.0)
|
|
30
|
-
rails-dom-testing (~> 2.2)
|
|
31
|
-
actionpack (8.0.0)
|
|
32
|
-
actionview (= 8.0.0)
|
|
33
|
-
activesupport (= 8.0.0)
|
|
34
|
-
nokogiri (>= 1.8.5)
|
|
35
|
-
rack (>= 2.2.4)
|
|
36
|
-
rack-session (>= 1.0.1)
|
|
37
|
-
rack-test (>= 0.6.3)
|
|
38
|
-
rails-dom-testing (~> 2.2)
|
|
39
|
-
rails-html-sanitizer (~> 1.6)
|
|
40
|
-
useragent (~> 0.16)
|
|
41
|
-
actiontext (8.0.0)
|
|
42
|
-
actionpack (= 8.0.0)
|
|
43
|
-
activerecord (= 8.0.0)
|
|
44
|
-
activestorage (= 8.0.0)
|
|
45
|
-
activesupport (= 8.0.0)
|
|
46
|
-
globalid (>= 0.6.0)
|
|
47
|
-
nokogiri (>= 1.8.5)
|
|
48
|
-
actionview (8.0.0)
|
|
49
|
-
activesupport (= 8.0.0)
|
|
50
|
-
builder (~> 3.1)
|
|
51
|
-
erubi (~> 1.11)
|
|
52
|
-
rails-dom-testing (~> 2.2)
|
|
53
|
-
rails-html-sanitizer (~> 1.6)
|
|
54
|
-
activejob (8.0.0)
|
|
55
|
-
activesupport (= 8.0.0)
|
|
56
|
-
globalid (>= 0.3.6)
|
|
57
|
-
activemodel (8.0.0)
|
|
58
|
-
activesupport (= 8.0.0)
|
|
59
|
-
activerecord (8.0.0)
|
|
60
|
-
activemodel (= 8.0.0)
|
|
61
|
-
activesupport (= 8.0.0)
|
|
62
|
-
timeout (>= 0.4.0)
|
|
63
|
-
activestorage (8.0.0)
|
|
64
|
-
actionpack (= 8.0.0)
|
|
65
|
-
activejob (= 8.0.0)
|
|
66
|
-
activerecord (= 8.0.0)
|
|
67
|
-
activesupport (= 8.0.0)
|
|
68
|
-
marcel (~> 1.0)
|
|
69
|
-
activesupport (8.0.0)
|
|
70
|
-
base64
|
|
71
|
-
benchmark (>= 0.3)
|
|
72
|
-
bigdecimal
|
|
73
|
-
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
74
|
-
connection_pool (>= 2.2.5)
|
|
75
|
-
drb
|
|
76
|
-
i18n (>= 1.6, < 2)
|
|
77
|
-
logger (>= 1.4.2)
|
|
78
|
-
minitest (>= 5.1)
|
|
79
|
-
securerandom (>= 0.3)
|
|
80
|
-
tzinfo (~> 2.0, >= 2.0.5)
|
|
81
|
-
uri (>= 0.13.1)
|
|
82
|
-
base64 (0.2.0)
|
|
83
|
-
benchmark (0.4.0)
|
|
84
|
-
bigdecimal (3.1.8)
|
|
85
|
-
bigdecimal (3.1.8-java)
|
|
86
|
-
builder (3.3.0)
|
|
87
|
-
concurrent-ruby (1.3.4)
|
|
88
|
-
connection_pool (2.4.1)
|
|
89
|
-
crass (1.0.6)
|
|
90
|
-
date (3.4.1)
|
|
91
|
-
date (3.4.1-java)
|
|
92
|
-
diff-lcs (1.5.1)
|
|
93
|
-
docile (1.4.1)
|
|
94
|
-
drb (2.2.1)
|
|
95
|
-
erubi (1.13.0)
|
|
96
|
-
globalid (1.2.1)
|
|
97
|
-
activesupport (>= 6.1)
|
|
98
|
-
i18n (1.14.6)
|
|
99
|
-
concurrent-ruby (~> 1.0)
|
|
100
|
-
io-console (0.8.0)
|
|
101
|
-
io-console (0.8.0-java)
|
|
102
|
-
irb (1.14.1)
|
|
103
|
-
rdoc (>= 4.0.0)
|
|
104
|
-
reline (>= 0.4.2)
|
|
105
|
-
jar-dependencies (0.5.0)
|
|
106
|
-
logger (1.6.2)
|
|
107
|
-
loofah (2.23.1)
|
|
108
|
-
crass (~> 1.0.2)
|
|
109
|
-
nokogiri (>= 1.12.0)
|
|
110
|
-
mail (2.8.1)
|
|
111
|
-
mini_mime (>= 0.1.1)
|
|
112
|
-
net-imap
|
|
113
|
-
net-pop
|
|
114
|
-
net-smtp
|
|
115
|
-
marcel (1.0.4)
|
|
116
|
-
mini_mime (1.1.5)
|
|
117
|
-
mini_portile2 (2.8.8)
|
|
118
|
-
minitest (5.25.4)
|
|
119
|
-
net-imap (0.5.1)
|
|
120
|
-
date
|
|
121
|
-
net-protocol
|
|
122
|
-
net-pop (0.1.2)
|
|
123
|
-
net-protocol
|
|
124
|
-
net-protocol (0.2.2)
|
|
125
|
-
timeout
|
|
126
|
-
net-smtp (0.5.0)
|
|
127
|
-
net-protocol
|
|
128
|
-
nio4r (2.7.4)
|
|
129
|
-
nio4r (2.7.4-java)
|
|
130
|
-
nokogiri (1.16.8-aarch64-linux)
|
|
131
|
-
racc (~> 1.4)
|
|
132
|
-
nokogiri (1.16.8-arm-linux)
|
|
133
|
-
racc (~> 1.4)
|
|
134
|
-
nokogiri (1.16.8-arm64-darwin)
|
|
135
|
-
racc (~> 1.4)
|
|
136
|
-
nokogiri (1.16.8-java)
|
|
137
|
-
racc (~> 1.4)
|
|
138
|
-
nokogiri (1.16.8-x86-linux)
|
|
139
|
-
racc (~> 1.4)
|
|
140
|
-
nokogiri (1.16.8-x86_64-darwin)
|
|
141
|
-
racc (~> 1.4)
|
|
142
|
-
nokogiri (1.16.8-x86_64-linux)
|
|
143
|
-
racc (~> 1.4)
|
|
144
|
-
psych (5.2.1)
|
|
145
|
-
date
|
|
146
|
-
stringio
|
|
147
|
-
psych (5.2.1-java)
|
|
148
|
-
date
|
|
149
|
-
jar-dependencies (>= 0.1.7)
|
|
150
|
-
racc (1.8.1)
|
|
151
|
-
racc (1.8.1-java)
|
|
152
|
-
rack (3.1.8)
|
|
153
|
-
rack-session (2.0.0)
|
|
154
|
-
rack (>= 3.0.0)
|
|
155
|
-
rack-test (2.1.0)
|
|
156
|
-
rack (>= 1.3)
|
|
157
|
-
rackup (2.2.1)
|
|
158
|
-
rack (>= 3)
|
|
159
|
-
rails (8.0.0)
|
|
160
|
-
actioncable (= 8.0.0)
|
|
161
|
-
actionmailbox (= 8.0.0)
|
|
162
|
-
actionmailer (= 8.0.0)
|
|
163
|
-
actionpack (= 8.0.0)
|
|
164
|
-
actiontext (= 8.0.0)
|
|
165
|
-
actionview (= 8.0.0)
|
|
166
|
-
activejob (= 8.0.0)
|
|
167
|
-
activemodel (= 8.0.0)
|
|
168
|
-
activerecord (= 8.0.0)
|
|
169
|
-
activestorage (= 8.0.0)
|
|
170
|
-
activesupport (= 8.0.0)
|
|
171
|
-
bundler (>= 1.15.0)
|
|
172
|
-
railties (= 8.0.0)
|
|
173
|
-
rails-dom-testing (2.2.0)
|
|
174
|
-
activesupport (>= 5.0.0)
|
|
175
|
-
minitest
|
|
176
|
-
nokogiri (>= 1.6)
|
|
177
|
-
rails-html-sanitizer (1.6.1)
|
|
178
|
-
loofah (~> 2.21)
|
|
179
|
-
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
180
|
-
railties (8.0.0)
|
|
181
|
-
actionpack (= 8.0.0)
|
|
182
|
-
activesupport (= 8.0.0)
|
|
183
|
-
irb (~> 1.13)
|
|
184
|
-
rackup (>= 1.0.0)
|
|
185
|
-
rake (>= 12.2)
|
|
186
|
-
thor (~> 1.0, >= 1.2.2)
|
|
187
|
-
zeitwerk (~> 2.6)
|
|
188
|
-
rake (13.2.1)
|
|
189
|
-
rdoc (6.8.1)
|
|
190
|
-
psych (>= 4.0.0)
|
|
191
|
-
reline (0.5.12)
|
|
192
|
-
io-console (~> 0.5)
|
|
193
|
-
rexml (3.3.9)
|
|
194
|
-
rspec (3.13.0)
|
|
195
|
-
rspec-core (~> 3.13.0)
|
|
196
|
-
rspec-expectations (~> 3.13.0)
|
|
197
|
-
rspec-mocks (~> 3.13.0)
|
|
198
|
-
rspec-core (3.13.2)
|
|
199
|
-
rspec-support (~> 3.13.0)
|
|
200
|
-
rspec-expectations (3.13.3)
|
|
201
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
202
|
-
rspec-support (~> 3.13.0)
|
|
203
|
-
rspec-mocks (3.13.2)
|
|
204
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
205
|
-
rspec-support (~> 3.13.0)
|
|
206
|
-
rspec-support (3.13.2)
|
|
207
|
-
rspec_junit_formatter (0.6.0)
|
|
208
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
|
209
|
-
securerandom (0.4.0)
|
|
210
|
-
simplecov (0.22.0)
|
|
211
|
-
docile (~> 1.1)
|
|
212
|
-
simplecov-html (~> 0.11)
|
|
213
|
-
simplecov_json_formatter (~> 0.1)
|
|
214
|
-
simplecov-cobertura (2.1.0)
|
|
215
|
-
rexml
|
|
216
|
-
simplecov (~> 0.19)
|
|
217
|
-
simplecov-html (0.13.1)
|
|
218
|
-
simplecov_json_formatter (0.1.4)
|
|
219
|
-
sqlite3 (2.4.0)
|
|
220
|
-
mini_portile2 (~> 2.8.0)
|
|
221
|
-
sqlite3 (2.4.0-aarch64-linux-gnu)
|
|
222
|
-
sqlite3 (2.4.0-arm-linux-gnu)
|
|
223
|
-
sqlite3 (2.4.0-arm64-darwin)
|
|
224
|
-
sqlite3 (2.4.0-x86-linux-gnu)
|
|
225
|
-
sqlite3 (2.4.0-x86_64-darwin)
|
|
226
|
-
sqlite3 (2.4.0-x86_64-linux-gnu)
|
|
227
|
-
stringio (3.1.2)
|
|
228
|
-
thor (1.3.2)
|
|
229
|
-
timeout (0.4.2)
|
|
230
|
-
tzinfo (2.0.6)
|
|
231
|
-
concurrent-ruby (~> 1.0)
|
|
232
|
-
uri (1.0.2)
|
|
233
|
-
useragent (0.16.11)
|
|
234
|
-
websocket-driver (0.7.6)
|
|
235
|
-
websocket-extensions (>= 0.1.0)
|
|
236
|
-
websocket-driver (0.7.6-java)
|
|
237
|
-
websocket-extensions (>= 0.1.0)
|
|
238
|
-
websocket-extensions (0.1.5)
|
|
239
|
-
zeitwerk (2.7.1)
|
|
240
|
-
|
|
241
|
-
PLATFORMS
|
|
242
|
-
aarch64-linux
|
|
243
|
-
arm-linux
|
|
244
|
-
arm64-darwin
|
|
245
|
-
universal-java-11
|
|
246
|
-
x86-linux
|
|
247
|
-
x86_64-darwin
|
|
248
|
-
x86_64-linux
|
|
249
|
-
|
|
250
|
-
DEPENDENCIES
|
|
251
|
-
bundler (~> 2)
|
|
252
|
-
rspec (~> 3)
|
|
253
|
-
rspec_junit_formatter (~> 0.6)
|
|
254
|
-
seed_builder!
|
|
255
|
-
simplecov (~> 0.21)
|
|
256
|
-
simplecov-cobertura (~> 2)
|
|
257
|
-
sqlite3 (~> 2.4)
|
|
258
|
-
|
|
259
|
-
BUNDLED WITH
|
|
260
|
-
2.5.20
|
data/lib/rails_config.rb
DELETED
data/spec/fixtures/schema.rb
DELETED
data/spec/fixtures/seeds.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
SeedUser.find_or_create_by(email: "test@example.com")
|
data/spec/generator_spec.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
require "generators/seed_generator"
|
|
4
|
-
|
|
5
|
-
describe SeedGenerator, type: :generator do
|
|
6
|
-
include FileUtils
|
|
7
|
-
|
|
8
|
-
subject(:generator) { described_class.start params }
|
|
9
|
-
let(:destination_root) { File.expand_path("../../tmp/rspec", __FILE__) }
|
|
10
|
-
let(:seeds_path) { rails_root.join("db/seeds") }
|
|
11
|
-
|
|
12
|
-
let(:seed_name) { "create_users" }
|
|
13
|
-
let(:params) { [seed_name] }
|
|
14
|
-
|
|
15
|
-
let(:created_files) { Dir["#{seeds_path}/*_#{seed_name}.rb"] }
|
|
16
|
-
let(:file_contents) { File.readlines(created_files.first).map(&:strip).reject(&:blank?) }
|
|
17
|
-
|
|
18
|
-
before do
|
|
19
|
-
mkdir_p destination_root
|
|
20
|
-
|
|
21
|
-
allow(SeedBuilder.config).to receive(:seeds_path).and_return(seeds_path)
|
|
22
|
-
allow(Rails).to receive(:root).and_return(rails_root(destination_root))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
after do
|
|
26
|
-
rm_rf destination_root
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "creates a migration file" do
|
|
30
|
-
generator
|
|
31
|
-
|
|
32
|
-
expect(created_files).not_to be_empty
|
|
33
|
-
expect(file_contents).to include("class CreateUsers")
|
|
34
|
-
expect(file_contents).not_to include("RSpec.describe CreateUsers")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context "when generate_spec is false" do
|
|
38
|
-
before do
|
|
39
|
-
allow(SeedBuilder.config).to receive(:generate_spec?).and_return(false)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "does not create a spec file" do
|
|
43
|
-
generator
|
|
44
|
-
|
|
45
|
-
expect(created_files).not_to be_empty
|
|
46
|
-
expect(file_contents).to include("class CreateUsers")
|
|
47
|
-
expect(file_contents).not_to include("RSpec.describe CreateUsers")
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe SeedBuilder::Config do
|
|
4
|
-
subject(:config) { described_class.new }
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
allow(Rails).to receive(:root).and_return(rails_root)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "has default seeds path" do
|
|
11
|
-
expect(config.seeds_path).to eq "db/seeds"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "has default load_seeds" do
|
|
15
|
-
expect(config.load_seeds?).to be true
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "has default load_default_seeds" do
|
|
19
|
-
expect(config.load_default_seeds?).to be true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "has default generate_spec" do
|
|
23
|
-
expect(config.generate_spec?).to be true
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "has default seeds_full_path" do
|
|
27
|
-
expect(config.seeds_full_path).to eq Rails.root.join("db/seeds")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "has default seeds_path_glob" do
|
|
31
|
-
expect(config.seeds_path_glob).to eq Rails.root.join("db/seeds/*.rb").to_s
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
class SeedBuilderUser < ActiveRecord::Base; end
|
|
4
|
-
|
|
5
|
-
class SeedUser < SeedBuilderUser; end
|
|
6
|
-
|
|
7
|
-
describe SeedBuilder::Loader do
|
|
8
|
-
subject(:loader) { described_class.new }
|
|
9
|
-
|
|
10
|
-
describe "#load_seed" do
|
|
11
|
-
let(:load_default_seeds) { true }
|
|
12
|
-
let(:load_seeds) { true }
|
|
13
|
-
let(:logger) { Logger.new($stdout) }
|
|
14
|
-
|
|
15
|
-
before do
|
|
16
|
-
allow(Rails).to receive(:root).and_return(rails_root)
|
|
17
|
-
allow(Rails).to receive(:env).and_return(rails_env)
|
|
18
|
-
allow(Rails).to receive(:logger).and_return(logger)
|
|
19
|
-
allow(Rails).to receive(:logger=)
|
|
20
|
-
|
|
21
|
-
SeedBuilder.configure do |config|
|
|
22
|
-
config.seeds_full_path = File.expand_path("../../fixtures/seeds", __FILE__)
|
|
23
|
-
config.default_seeds_full_path = File.expand_path("../../fixtures/seeds.rb", __FILE__)
|
|
24
|
-
config.load_default_seeds = load_default_seeds
|
|
25
|
-
config.load_seeds = load_seeds
|
|
26
|
-
end
|
|
27
|
-
loader.load_seed
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "loads the seeds" do
|
|
31
|
-
expect(SeedUser.count).to eq 1
|
|
32
|
-
expect(SeedBuilderUser.count).to eq 1
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
data/spec/seed_builder_spec.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe SeedBuilder do
|
|
4
|
-
let(:gem_specification) { Gem::Specification.load(File.expand_path("../../seed_builder.gemspec", __FILE__)) }
|
|
5
|
-
|
|
6
|
-
it "has a version number" do
|
|
7
|
-
expect(described_class::VERSION).to eq gem_specification.version.to_s
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
let(:changelog_file) { File.expand_path("../../CHANGELOG.md", __FILE__) }
|
|
11
|
-
it "has changelog for the version" do
|
|
12
|
-
expect(File.exist?(changelog_file)).to be true
|
|
13
|
-
expect(File.read(changelog_file)).to include("# #{gem_specification.version}")
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
let(:license_file) { File.expand_path("../../LICENSE.md", __FILE__) }
|
|
17
|
-
it "has license" do
|
|
18
|
-
expect(File.exist?(license_file)).to be true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
let(:readme_file) { File.expand_path("../../README.md", __FILE__) }
|
|
22
|
-
it "has readme" do
|
|
23
|
-
expect(File.exist?(readme_file)).to be true
|
|
24
|
-
end
|
|
25
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "simplecov"
|
|
2
|
-
SimpleCov.start do
|
|
3
|
-
add_filter "/spec/"
|
|
4
|
-
add_filter { |source_file| source_file.lines.count < 5 }
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
require "simplecov-cobertura"
|
|
8
|
-
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
|
9
|
-
|
|
10
|
-
require "active_record"
|
|
11
|
-
|
|
12
|
-
require "seed_builder"
|
|
13
|
-
|
|
14
|
-
Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require_relative f }
|
|
15
|
-
|
|
16
|
-
RSpec.configure do |config|
|
|
17
|
-
include RailsHelpers
|
|
18
|
-
|
|
19
|
-
config.before(:suite) do
|
|
20
|
-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
|
21
|
-
load File.expand_path("../fixtures/schema.rb", __FILE__)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module RailsHelpers
|
|
2
|
-
def rails_root(destination_root = File.expand_path("../../tmp/rspec", __dir__))
|
|
3
|
-
Class.new do
|
|
4
|
-
def initialize(destination_root)
|
|
5
|
-
@destination_root = destination_root
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def to_s
|
|
9
|
-
@destination_root
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def join(*args)
|
|
13
|
-
File.join(@destination_root, *args)
|
|
14
|
-
end
|
|
15
|
-
end.new(destination_root)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def rails_env(env = "development")
|
|
19
|
-
Class.new do
|
|
20
|
-
def initialize(env)
|
|
21
|
-
@env = env.to_s
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def development?
|
|
25
|
-
@env == "development"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test?
|
|
29
|
-
@env == "test"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def production?
|
|
33
|
-
@env == "production"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def to_s
|
|
37
|
-
@env
|
|
38
|
-
end
|
|
39
|
-
end.new(env)
|
|
40
|
-
end
|
|
41
|
-
end
|
data/usr/bin/release.sh
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -e
|
|
4
|
-
|
|
5
|
-
e() {
|
|
6
|
-
GREEN='\033[0;32m'
|
|
7
|
-
NC='\033[0m'
|
|
8
|
-
echo -e "${GREEN}$1${NC}"
|
|
9
|
-
eval "$1"
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
e "bundle"
|
|
13
|
-
e "bundle exec rspec"
|
|
14
|
-
|
|
15
|
-
if [[ $(git diff --shortstat 2>/dev/null | tail -n1) != "" ]]; then
|
|
16
|
-
echo -e "\033[1;31mgit working directory not clean, please commit your changes first \033[0m"
|
|
17
|
-
exit 1
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
GEM_NAME="seed_builder"
|
|
21
|
-
VERSION=$(grep -Eo "VERSION\s*=\s*\".+\"" lib/seed_builder.rb | grep -Eo "[0-9.]{5,}")
|
|
22
|
-
GEM_FILE="$GEM_NAME-$VERSION.gem"
|
|
23
|
-
|
|
24
|
-
e "gem build $GEM_NAME.gemspec"
|
|
25
|
-
|
|
26
|
-
echo "Ready to release $GEM_FILE $VERSION"
|
|
27
|
-
read -p "Continue? [Y/n] " answer
|
|
28
|
-
if [[ "$answer" != "Y" ]]; then
|
|
29
|
-
echo "Exiting"
|
|
30
|
-
exit 1
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
e "gem push $GEM_FILE"
|
|
34
|
-
e "git tag $VERSION && git push --tags"
|
|
35
|
-
e "gh release create $VERSION --generate-notes"
|