Sha256: 940805dd283069f3497e5355b1216706d840d0690f555558fbe53e188d47a6d1
Contents?: true
Size: 1.62 KB
Versions: 5
Compression:
Stored size: 1.62 KB
Contents
module Souls class Generate < Thor desc "rspec_job [CLASS_NAME]", "Generate Rspec Job Test Template" def rspec_job(class_name) singularized_class_name = class_name.underscore.singularize file_dir = "./spec/mutations/jobs/" FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) file_path = "#{file_dir}/#{singularized_class_name}_spec.rb" return "RspecJob already exist! #{file_path}" if File.exist?(file_path) File.open(file_path, "w") do |f| f.write(<<~TEXT) RSpec.describe("#{singularized_class_name.camelize}") do describe "Define #{singularized_class_name.camelize}" do let(:mutation) do %(mutation { #{singularized_class_name.camelize(:lower)}(input: {}) { response } } ) end subject(:result) do SoulsApiSchema.execute(mutation).as_json end it "return StockSheet Data" do begin a1 = result.dig("data", "#{singularized_class_name.camelize(:lower)}", "response") raise unless a1.present? rescue StandardError raise(StandardError, result) end expect(a1).to(include("response" => be_a(String))) end end end TEXT end puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }]) file_path rescue Thor::Error => e raise(Thor::Error, e) end end end
Version data entries
5 entries across 5 versions & 1 rubygems