class ProxyTester::UserDatabase
Attributes
file[R]
Public Class Methods
new(file = ProxyTester.config.user_file)
click to toggle source
# File lib/proxy_tester/user_database.rb, line 10 def initialize(file = ProxyTester.config.user_file) @file = file end
Public Instance Methods
create_users(creator)
click to toggle source
# File lib/proxy_tester/user_database.rb, line 14 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