0
サービスからのcsvアップロードを実装するコードがあります。CSVアップロードのためのRspec
require 'csv'
class ActualCsvProjectUpdater
def self.import(file, project)
CSV.foreach(file.path, headers: true) do |row|
actual_billable_hours, actual_non_billable_hours, start_date = row['actual_billable_hours'], row['actual_non_billable_hours'], row['start_date']
week = project.weeks.find_by(start_date: start_date)
if week.present?
week.update!(actual_billable_hours: row['actual_billable_hours'], actual_non_billable_hours: row['actual_non_billable_hours'])
end
end
end
end`
これはどのようにテストするのですか?
テストではいくつかのフィクスチャを愛しています。クラスでは、インストラクターは誰もテストスイートを30秒未満で実行できるとは思わなかった。鉱山は備品の2秒間に入った。また、 'factory_girl'も役立ちます –