souls 0.23.5 → 0.23.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +73 -138
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -2
- data/exe/souls +68 -68
- data/lib/souls.rb +153 -141
- data/lib/souls/gcloud/compute.rb +61 -51
- data/lib/souls/gcloud/iam.rb +22 -24
- data/lib/souls/generate/application.rb +160 -160
- data/lib/souls/generate/connection.rb +13 -15
- data/lib/souls/generate/edge.rb +13 -15
- data/lib/souls/generate/model.rb +16 -17
- data/lib/souls/generate/mutation.rb +225 -221
- data/lib/souls/generate/policy.rb +44 -45
- data/lib/souls/generate/query.rb +49 -49
- data/lib/souls/generate/resolver.rb +121 -124
- data/lib/souls/generate/rspec_factory.rb +49 -52
- data/lib/souls/generate/rspec_model.rb +17 -18
- data/lib/souls/generate/rspec_mutation.rb +193 -199
- data/lib/souls/generate/rspec_policy.rb +38 -39
- data/lib/souls/generate/rspec_query.rb +133 -140
- data/lib/souls/generate/rspec_resolver.rb +147 -154
- data/lib/souls/generate/type.rb +34 -25
- data/lib/souls/init.rb +51 -50
- data/lib/souls/version.rb +2 -1
- data/souls.gemspec +12 -7
- metadata +5 -5
@@ -1,68 +1,65 @@
|
|
1
1
|
module Souls
|
2
2
|
module Generate
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
EOS
|
13
|
-
end
|
3
|
+
## Generate Rspec Factory
|
4
|
+
def self.rspec_factory_head(class_name: "souls")
|
5
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
6
|
+
FileUtils.mkdir_p("./spec/factories/") unless Dir.exist?("./spec/factories/")
|
7
|
+
File.open(file_path, "w") do |f|
|
8
|
+
f.write(<<~TEXT)
|
9
|
+
FactoryBot.define do
|
10
|
+
factory :#{class_name} do
|
11
|
+
TEXT
|
14
12
|
end
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
if table_check(line: line, class_name: class_name)
|
36
|
-
@on = true
|
15
|
+
def self.rspec_factory_params(class_name: "souls")
|
16
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
17
|
+
path = "./db/schema.rb"
|
18
|
+
@on = false
|
19
|
+
File.open(file_path, "a") do |new_line|
|
20
|
+
File.open(path, "r") do |f|
|
21
|
+
f.each_line.with_index do |line, _i|
|
22
|
+
if @on
|
23
|
+
new_line.write("\n" && break) if line.include?("end") || line.include?("t.index")
|
24
|
+
field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
|
25
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
26
|
+
field ||= get_test_type(type)
|
27
|
+
if type == "bigint" && name.include?("_id")
|
28
|
+
id_name = name.gsub("_id", "")
|
29
|
+
new_line.write(" association :#{id_name}, factory: :#{id_name}\n")
|
30
|
+
else
|
31
|
+
new_line.write(" #{name} { #{field} }\n")
|
37
32
|
end
|
38
33
|
end
|
34
|
+
@on = true if table_check(line: line, class_name: class_name)
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
38
|
+
end
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
40
|
+
def self.rspec_factory_end(class_name: "souls")
|
41
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
42
|
+
File.open(file_path, "a") do |f|
|
43
|
+
f.write(<<~TEXT)
|
48
44
|
end
|
49
|
-
|
50
|
-
|
51
|
-
file_path
|
45
|
+
end
|
46
|
+
TEXT
|
52
47
|
end
|
48
|
+
file_path
|
49
|
+
end
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
51
|
+
def self.rspec_factory(class_name: "souls")
|
52
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
53
|
+
return "RspecFactory already exist! #{file_path}" if File.exist?(file_path)
|
54
|
+
|
55
|
+
singularized_class_name = class_name.singularize
|
56
|
+
rspec_factory_head(class_name: singularized_class_name)
|
57
|
+
rspec_factory_params(class_name: singularized_class_name)
|
58
|
+
rspec_factory_end(class_name: singularized_class_name)
|
59
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
60
|
+
file_path
|
61
|
+
rescue StandardError => e
|
62
|
+
raise(StandardError, e)
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|
@@ -1,26 +1,25 @@
|
|
1
1
|
module Souls
|
2
2
|
module Generate
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
3
|
+
## Generate Rspec Model
|
4
|
+
def self.rspec_model(class_name: "souls")
|
5
|
+
file_path = "./spec/models/#{class_name}_spec.rb"
|
6
|
+
return "RspecModel already exist! #{file_path}" if File.exist?(file_path)
|
7
|
+
|
8
|
+
File.open(file_path, "w") do |f|
|
9
|
+
f.write(<<~TEXT)
|
10
|
+
RSpec.describe "#{class_name.camelize} Model テスト", type: :model do
|
11
|
+
describe "#{class_name.camelize} データを書き込む" do
|
12
|
+
it "valid #{class_name.camelize} Model" do
|
13
|
+
expect(FactoryBot.build(:#{class_name.singularize})).to be_valid
|
15
14
|
end
|
16
15
|
end
|
17
|
-
|
18
|
-
|
19
|
-
puts Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }]
|
20
|
-
file_path
|
21
|
-
rescue StandardError => e
|
22
|
-
raise StandardError, e
|
16
|
+
end
|
17
|
+
TEXT
|
23
18
|
end
|
19
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
20
|
+
file_path
|
21
|
+
rescue StandardError => e
|
22
|
+
raise(StandardError, e)
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -1,253 +1,247 @@
|
|
1
1
|
module Souls
|
2
2
|
module Generate
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
EOS
|
12
|
-
end
|
3
|
+
## Generate Rspec Mutation
|
4
|
+
def self.rspec_mutation_head(class_name: "souls")
|
5
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
6
|
+
File.open(file_path, "w") do |f|
|
7
|
+
f.write(<<~TEXT)
|
8
|
+
RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
|
9
|
+
describe "#{class_name.camelize} データを登録する" do
|
10
|
+
TEXT
|
13
11
|
end
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
def self.rspec_mutation_after_head(class_name: "souls")
|
15
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
16
|
+
path = "./db/schema.rb"
|
17
|
+
@on = false
|
18
|
+
@user_exist = false
|
19
|
+
@relation_params = []
|
20
|
+
File.open(file_path, "a") do |new_line|
|
21
|
+
File.open(path, "r") do |f|
|
22
|
+
f.each_line.with_index do |line, _i|
|
23
|
+
if @on
|
24
|
+
if line.include?("end") || line.include?("t.index")
|
25
|
+
if @relation_params.empty?
|
26
|
+
new_line.write(<<-TEXT)
|
27
|
+
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}) }
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
let(:mutation) do
|
30
|
+
%(mutation {
|
31
|
+
create#{class_name.camelize}(input: {
|
32
|
+
TEXT
|
33
|
+
else
|
34
|
+
new_line.write(<<-TEXT)
|
35
|
+
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(', ')}) }
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
break
|
44
|
-
end
|
45
|
-
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
46
|
-
case name
|
47
|
-
when "user_id"
|
48
|
-
relation_col = name.gsub("_id", "")
|
49
|
-
new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
|
50
|
-
when /$*_id\z/
|
51
|
-
relation_col = name.gsub("_id", "")
|
52
|
-
@relation_params << "#{name}: get_global_key(\"#{name.singularize.camelize.gsub("Id", "")}\", #{relation_col}.id)"
|
53
|
-
new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
|
37
|
+
let(:mutation) do
|
38
|
+
%(mutation {
|
39
|
+
create#{class_name.camelize}(input: {
|
40
|
+
TEXT
|
54
41
|
end
|
42
|
+
break
|
55
43
|
end
|
56
|
-
|
57
|
-
|
44
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
45
|
+
case name
|
46
|
+
when "user_id"
|
47
|
+
relation_col = name.gsub("_id", "")
|
48
|
+
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
49
|
+
when /$*_id\z/
|
50
|
+
relation_col = name.gsub("_id", "")
|
51
|
+
@relation_params << "#{name}: get_global_key(\"#{name.singularize.camelize.gsub(
|
52
|
+
'Id',
|
53
|
+
''
|
54
|
+
)}\", #{relation_col}.id)"
|
55
|
+
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
58
56
|
end
|
59
57
|
end
|
58
|
+
@on = true if table_check(line: line, class_name: class_name)
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
when "bigint", "integer", "float", "boolean"
|
96
|
-
new_line.write " #{name.singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
64
|
+
def self.rspec_mutation_params(class_name: "souls")
|
65
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
66
|
+
path = "./db/schema.rb"
|
67
|
+
@on = false
|
68
|
+
@user_exist = false
|
69
|
+
File.open(file_path, "a") do |new_line|
|
70
|
+
File.open(path, "r") do |f|
|
71
|
+
f.each_line.with_index do |line, _i|
|
72
|
+
if @on
|
73
|
+
if line.include?("end") || line.include?("t.index")
|
74
|
+
new_line.write(" }) {\n #{class_name.singularize.camelize(:lower)}Edge {\n node {\n")
|
75
|
+
new_line.write(" id\n")
|
76
|
+
break
|
77
|
+
end
|
78
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
79
|
+
array_true = line.include?("array: true")
|
80
|
+
case name
|
81
|
+
when "created_at", "updated_at"
|
82
|
+
next
|
83
|
+
when "user_id"
|
84
|
+
@user_exist = true
|
85
|
+
when /$*_id\z/
|
86
|
+
new_line.write(" #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n")
|
87
|
+
else
|
88
|
+
case type
|
89
|
+
when "string", "text", "date", "datetime"
|
90
|
+
if array_true
|
91
|
+
new_line.write(" #{name.pluralize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n")
|
92
|
+
else
|
93
|
+
new_line.write(" #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n")
|
97
94
|
end
|
95
|
+
when "bigint", "integer", "float", "boolean"
|
96
|
+
new_line.write(" #{name.singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n")
|
98
97
|
end
|
99
98
|
end
|
100
|
-
if table_check(line: line, class_name: class_name)
|
101
|
-
@on = true
|
102
|
-
end
|
103
99
|
end
|
100
|
+
@on = true if table_check(line: line, class_name: class_name)
|
104
101
|
end
|
105
102
|
end
|
106
103
|
end
|
104
|
+
end
|
107
105
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
106
|
+
def self.rspec_mutation_params_response(class_name: "souls")
|
107
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
108
|
+
path = "./db/schema.rb"
|
109
|
+
@on = false
|
110
|
+
File.open(file_path, "a") do |new_line|
|
111
|
+
File.open(path, "r") do |f|
|
112
|
+
f.each_line.with_index do |line, _i|
|
113
|
+
if @on
|
114
|
+
if line.include?("end") || line.include?("t.index")
|
115
|
+
if @user_exist
|
116
|
+
new_line.write(<<-TEXT)
|
120
117
|
}
|
121
118
|
}
|
122
119
|
}
|
123
|
-
)
|
124
|
-
end
|
125
|
-
|
126
|
-
subject(:result) do
|
127
|
-
context = {
|
128
|
-
user: user
|
129
120
|
}
|
130
|
-
|
131
|
-
|
121
|
+
)
|
122
|
+
end
|
132
123
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
124
|
+
subject(:result) do
|
125
|
+
context = {
|
126
|
+
user: user
|
127
|
+
}
|
128
|
+
SoulsApiSchema.execute(mutation, context: context).as_json
|
129
|
+
end
|
130
|
+
|
131
|
+
it "return #{class_name.camelize} Data" do
|
132
|
+
begin
|
133
|
+
a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
|
134
|
+
raise unless a1.present?
|
135
|
+
rescue
|
136
|
+
raise StandardError, result
|
137
|
+
end
|
138
|
+
expect(a1).to include(
|
139
|
+
"id" => be_a(String),
|
140
|
+
TEXT
|
141
|
+
else
|
142
|
+
new_line.write(<<-TEXT)
|
146
143
|
}
|
147
144
|
}
|
148
145
|
}
|
149
|
-
|
150
|
-
|
146
|
+
}
|
147
|
+
)
|
148
|
+
end
|
151
149
|
|
152
|
-
|
153
|
-
|
154
|
-
|
150
|
+
subject(:result) do
|
151
|
+
SoulsApiSchema.execute(mutation).as_json
|
152
|
+
end
|
155
153
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end
|
167
|
-
break
|
154
|
+
it "return #{class_name.camelize} Data" do
|
155
|
+
begin
|
156
|
+
a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
|
157
|
+
raise unless a1.present?
|
158
|
+
rescue
|
159
|
+
raise StandardError, result
|
160
|
+
end
|
161
|
+
expect(a1).to include(
|
162
|
+
"id" => be_a(String),
|
163
|
+
TEXT
|
168
164
|
end
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
165
|
+
break
|
166
|
+
end
|
167
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
168
|
+
array_true = line.include?("array: true")
|
169
|
+
case name
|
170
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
171
|
+
next
|
172
|
+
else
|
173
|
+
if array_true
|
174
|
+
new_line.write(" #{name.pluralize.camelize(:lower)}\n")
|
174
175
|
else
|
175
|
-
|
176
|
-
new_line.write " #{name.pluralize.camelize(:lower)}\n"
|
177
|
-
else
|
178
|
-
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
179
|
-
end
|
176
|
+
new_line.write(" #{name.singularize.camelize(:lower)}\n")
|
180
177
|
end
|
181
178
|
end
|
182
|
-
if table_check(line: line, class_name: class_name)
|
183
|
-
@on = true
|
184
|
-
end
|
185
179
|
end
|
180
|
+
@on = true if table_check(line: line, class_name: class_name)
|
186
181
|
end
|
187
182
|
end
|
188
183
|
end
|
184
|
+
end
|
189
185
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
186
|
+
def self.rspec_mutation_end(class_name: "souls")
|
187
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
188
|
+
path = "./db/schema.rb"
|
189
|
+
@on = false
|
190
|
+
File.open(file_path, "a") do |new_line|
|
191
|
+
File.open(path, "r") do |f|
|
192
|
+
f.each_line.with_index do |line, _i|
|
193
|
+
if @on
|
194
|
+
if line.include?("end") || line.include?("t.index")
|
195
|
+
new_line.write(<<~TEXT)
|
196
|
+
)
|
202
197
|
end
|
203
198
|
end
|
204
|
-
EOS
|
205
|
-
break
|
206
|
-
end
|
207
|
-
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
208
|
-
field ||= type_check type
|
209
|
-
array_true = line.include?("array: true")
|
210
|
-
case name
|
211
|
-
when "user_id", "created_at", "updated_at", /$*_id\z/
|
212
|
-
next
|
213
|
-
else
|
214
|
-
case type
|
215
|
-
when "text", "date", "datetime"
|
216
|
-
if array_true
|
217
|
-
new_line.write " \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n"
|
218
|
-
else
|
219
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
|
220
|
-
end
|
221
|
-
when "boolean"
|
222
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
|
223
|
-
when "string", "bigint", "integer", "float"
|
224
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
225
199
|
end
|
226
|
-
|
200
|
+
TEXT
|
201
|
+
break
|
227
202
|
end
|
228
|
-
|
229
|
-
|
203
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
204
|
+
field ||= type_check(type)
|
205
|
+
array_true = line.include?("array: true")
|
206
|
+
case name
|
207
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
208
|
+
next
|
209
|
+
else
|
210
|
+
case type
|
211
|
+
when "text", "date", "datetime"
|
212
|
+
if array_true
|
213
|
+
new_line.write(" \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n")
|
214
|
+
else
|
215
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n")
|
216
|
+
end
|
217
|
+
when "boolean"
|
218
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n")
|
219
|
+
when "string", "bigint", "integer", "float"
|
220
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n")
|
221
|
+
end
|
230
222
|
end
|
231
223
|
end
|
224
|
+
@on = true if table_check(line: line, class_name: class_name)
|
232
225
|
end
|
233
226
|
end
|
234
|
-
file_path
|
235
227
|
end
|
228
|
+
file_path
|
229
|
+
end
|
236
230
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
231
|
+
def self.rspec_mutation(class_name: "souls")
|
232
|
+
singularized_class_name = class_name.singularize
|
233
|
+
file_path = "./spec/mutations/base/#{singularized_class_name}_spec.rb"
|
234
|
+
return "RspecMutation already exist! #{file_path}" if File.exist?(file_path)
|
235
|
+
|
236
|
+
rspec_mutation_head(class_name: singularized_class_name)
|
237
|
+
rspec_mutation_after_head(class_name: singularized_class_name)
|
238
|
+
rspec_mutation_params(class_name: singularized_class_name)
|
239
|
+
rspec_mutation_params_response(class_name: singularized_class_name)
|
240
|
+
rspec_mutation_end(class_name: singularized_class_name)
|
241
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
242
|
+
file_path
|
243
|
+
rescue StandardError => e
|
244
|
+
raise(StandardError, e)
|
251
245
|
end
|
252
246
|
end
|
253
247
|
end
|