Sha256: 795977f1aec5793ee1e72ef1c8e4c9e4f2c6fb44faccc481f2a0e5e279c3c498
Contents?: true
Size: 923 Bytes
Versions: 6
Compression:
Stored size: 923 Bytes
Contents
module Souls module Generate class << self ## Generate Rspec Model def rspec_model class_name: "souls" 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 <<~EOS 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 EOS 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 end
Version data entries
6 entries across 6 versions & 1 rubygems