5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/souls/cli/generate/rspec_manager.rb', line 5
def rspec_manager(class_name)
singularized_class_name = class_name.underscore.singularize
file_dir = "./spec/managers/#{singularized_class_name}_manager"
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
file_path = "#{file_dir}/#{options[:mutation]}_spec.rb"
return "RspecManager already exist! #{file_path}" if File.exist?(file_path)
File.open(file_path, "w") do |f|
f.write(<<~TEXT)
RSpec.describe("#{options[:mutation].singularize.camelize}") do
describe "Define #{options[:mutation].singularize.camelize}" do
let(:mutation) do
%(mutation {
#{options[:mutation].singularize.camelize(:lower)}(input: {
argument: "argument test!"
}) {
response
}
}
)
end
subject(:result) do
SOULsApiSchema.execute(mutation).as_json
end
it "return User response" do
begin
a1 = result.dig("data", "#{options[:mutation].singularize.camelize(:lower)}", "response")
raise unless a1.present?
rescue StandardError
raise(StandardError, result)
end
expect(a1).to(eq("success!"))
end
end
end
TEXT
end
SOULs::Painter.create_file(file_path.to_s)
file_path
end
|