Sha256: a06710684f487a8e9e1b23e33a2e939e537e59c6d731b66340f30373a42f73ac
Contents?: true
Size: 1.73 KB
Versions: 34
Compression:
Stored size: 1.73 KB
Contents
module Souls class Generate < Thor desc "rspec_manager [CLASS_NAME]", "Generate Rspec Manager Test Template" method_option :mutation, aliases: "--mutation", required: true, desc: "Mutation File Name" def rspec_manager(class_name) singularized_class_name = class_name.underscore.singularize file_dir = "./spec/managers/" FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) file_path = "./spec/mutations/managers/#{singularized_class_name}/#{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: {}) { 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(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 end end end
Version data entries
34 entries across 34 versions & 1 rubygems