Sha256: a0857efaaa0f8d3adabaa07441dfb8db641c2598df448ae510cc1bf43d505b10

Contents?: true

Size: 966 Bytes

Versions: 42

Compression:

Stored size: 966 Bytes

Contents

module Souls
  module Generate
    ## Generate Rspec Model
    def self.rspec_model(class_name: "souls")
      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 StandardError => e
      raise(StandardError, e)
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
souls-0.28.12 lib/souls/generate/rspec_model.rb
souls-0.28.11 lib/souls/generate/rspec_model.rb
souls-0.28.10 lib/souls/generate/rspec_model.rb
souls-0.28.9 lib/souls/generate/rspec_model.rb
souls-0.28.8 lib/souls/generate/rspec_model.rb
souls-0.28.7 lib/souls/generate/rspec_model.rb
souls-0.28.6 lib/souls/generate/rspec_model.rb
souls-0.28.5 lib/souls/generate/rspec_model.rb
souls-0.28.4 lib/souls/generate/rspec_model.rb
souls-0.28.3 lib/souls/generate/rspec_model.rb
souls-0.28.2 lib/souls/generate/rspec_model.rb
souls-0.28.1 lib/souls/generate/rspec_model.rb
souls-0.28.0 lib/souls/generate/rspec_model.rb
souls-0.27.8 lib/souls/generate/rspec_model.rb
souls-0.27.7 lib/souls/generate/rspec_model.rb
souls-0.27.6 lib/souls/generate/rspec_model.rb
souls-0.27.5 lib/souls/generate/rspec_model.rb
souls-0.27.4 lib/souls/generate/rspec_model.rb
souls-0.27.3 lib/souls/generate/rspec_model.rb
souls-0.27.2 lib/souls/generate/rspec_model.rb