Sha256: ff402fc1caed733c3eef6050b87b78ca2657c01106dcb1666dfc66ccafe207ba

Contents?: true

Size: 889 Bytes

Versions: 28

Compression:

Stored size: 889 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
      Souls::Painter.create_file(file_path.to_s)
      file_path
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
souls-1.17.3 lib/souls/cli/db/rspec_model.rb
souls-1.17.2 lib/souls/cli/db/rspec_model.rb
souls-1.17.1 lib/souls/cli/db/rspec_model.rb
souls-1.17.0 lib/souls/cli/db/rspec_model.rb
souls-1.16.4 lib/souls/cli/db/rspec_model.rb
souls-1.16.3 lib/souls/cli/db/rspec_model.rb
souls-1.16.2 lib/souls/cli/db/rspec_model.rb
souls-1.16.1 lib/souls/cli/db/rspec_model.rb
souls-1.16.0 lib/souls/cli/db/rspec_model.rb
souls-1.15.5 lib/souls/cli/db/rspec_model.rb
souls-1.15.4 lib/souls/cli/db/rspec_model.rb
souls-1.15.3 lib/souls/cli/db/rspec_model.rb
souls-1.15.2 lib/souls/cli/db/rspec_model.rb
souls-1.15.1 lib/souls/cli/db/rspec_model.rb
souls-1.15.0 lib/souls/cli/db/rspec_model.rb
souls-1.14.3 lib/souls/cli/db/rspec_model.rb
souls-1.14.2 lib/souls/cli/db/rspec_model.rb
souls-1.14.1 lib/souls/cli/db/rspec_model.rb
souls-1.14.0 lib/souls/cli/db/rspec_model.rb
souls-1.13.8 lib/souls/cli/db/rspec_model.rb