# encoding: utf-8 module ProxyTester class UserDatabase private attr_reader :file public def initialize(file = ProxyTester.config.user_file) @file = file end def create_users(creator) fail Exceptions::UserFileNotFound, JSON.dump(file: file) unless ::File.exist? file CSV.foreach(file, headers: true) do |r| creator.create! name: r['name'], password: r['password'] end rescue ActiveRecord::RecordInvalid => err raise Exceptions::UserRecordInvalid, JSON.dump(message: err.message) end end end