Rails 4 Minitest Testing Virtual Attributes
问题 So I have a class TimeBank, and its being updated, and is getting two new virtual attributes which will manipulate two other existing attributes (DB columns). class TimeBank < ActiveRecord::Base # validations, consts, few other methods omitted for brevity def date_worked @date_worked ||= self.start.to_date rescue Date.current end def date_worked=(date_worked_val) self.attributes['date_worked'] = date_worked_val end def hours_worked @hours_worked ||= hours rescue NoMethodError nil end def