What tests would you write for these two simple Ruby objects
Imagine you wrote this simple PORO in your Ruby on Rails app:
class CreditCard::AgeValidator def initialize(age) @age = age end def valid? return true if @age >= 18 false end end
What tests would you write for it?Â
What cases would you cover with your tests? How many tests would you write?
What about this update_required? method.Â
What cases would you cover when testing Account#update_required?Â
What cases would you cover with your tests? How many tests would you write?
class Account < ApplicationRecord \# t.date "expires_at" \# t.string "website" def update_required? website.blank? || expired? end def eternal? = expires_at.nil? def expired? return false if eternal? expires_at < Date.current end end