lib/souls/generate/rspec_resolver.rb in souls-0.25.12 vs lib/souls/generate/rspec_resolver.rb in souls-0.25.13
- old
+ new
@@ -1,9 +1,11 @@
module Souls
module Generate
## Generate Rspec Resolver
def self.rspec_resolver_head(class_name: "souls")
+ file_dir = "./spec/resolvers/"
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
File.open(file_path, "w") do |f|
f.write(<<~TEXT)
RSpec.describe \"#{class_name.camelize}Search Resolver テスト\" do
describe "削除フラグ false の #{class_name.camelize} を返却する" do
@@ -168,10 +170,10 @@
file_path
end
def self.rspec_resolver(class_name: "souls")
singularized_class_name = class_name.singularize
- file_path = "#{Dir.pwd}/spec/resolvers/#{singularized_class_name}_search_spec.rb"
+ file_path = "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
return "Resolver already exist! #{file_path}" if File.exist?(file_path)
rspec_resolver_head(class_name: singularized_class_name)
rspec_resolver_after_head(class_name: singularized_class_name)
rspec_resolver_params(class_name: singularized_class_name)