Sha256: da241615879845f0d5f72ba7f0e2252a322950c9883018f3c8af0ca7fed2f445

Contents?: true

Size: 1000 Bytes

Versions: 155

Compression:

Stored size: 1000 Bytes

Contents

module Souls
  class DB < Thor
    desc "rspec_model [CLASS_NAME]", "Generate Rspec Model Test from schema.rb"
    def rspec_model(class_name)
      file_dir = "./spec/models/"
      FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
      file_path = "./spec/models/#{class_name}_spec.rb"
      return "RspecModel already exist! #{file_path}" if File.exist?(file_path)

      File.open(file_path, "w") do |f|
        f.write(<<~TEXT)
          RSpec.describe "#{class_name.camelize} Model テスト", type: :model do
            describe "#{class_name.camelize} データを書き込む" do
              it "valid #{class_name.camelize} Model" do
                expect(FactoryBot.build(:#{class_name.singularize})).to be_valid
              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

155 entries across 155 versions & 1 rubygems

Version Path
souls-1.8.3 lib/souls/cli/db/rspec_model.rb
souls-1.8.2 lib/souls/cli/db/rspec_model.rb
souls-1.8.1 lib/souls/cli/db/rspec_model.rb
souls-1.8.0 lib/souls/cli/db/rspec_model.rb
souls-1.7.38 lib/souls/cli/db/rspec_model.rb
souls-1.7.37 lib/souls/cli/db/rspec_model.rb
souls-1.7.36 lib/souls/cli/db/rspec_model.rb
souls-1.7.34 lib/souls/cli/db/rspec_model.rb
souls-1.7.33 lib/souls/cli/db/rspec_model.rb
souls-1.7.32 lib/souls/cli/db/rspec_model.rb
souls-1.7.31 lib/souls/cli/db/rspec_model.rb
souls-1.7.30 lib/souls/cli/db/rspec_model.rb
souls-1.7.29 lib/souls/cli/db/rspec_model.rb
souls-1.7.28 lib/souls/cli/db/rspec_model.rb
souls-1.7.27 lib/souls/cli/db/rspec_model.rb
souls-1.7.26 lib/souls/cli/db/rspec_model.rb
souls-1.7.25 lib/souls/cli/db/rspec_model.rb
souls-1.7.24 lib/souls/cli/db/rspec_model.rb
souls-1.7.21 lib/souls/cli/db/rspec_model.rb
souls-1.7.20 lib/souls/cli/db/rspec_model.rb