Test Spies

Test spies are a wonderful tool to utilize in the RSpec testing environment. When used in moderation and with care. Test spies require that a called method be stubbed so that it can be checked to see how it was invoked. I have put together a really simple class to demonstrate a test spy. class NotifyUser attr_reader :user def initialize(user) @user = user end def execute(params={}) mailer....

October 1, 2013

Ruby Mixin Exploration

Recently I’ve been playing with Ruby’s class_eval and define_method to append methods to an object. Meta programming is something new for me and I had a problem that would benefit from using some of Ruby’s cool features. The Problem There was a model that had 6 fields that needed to be generated at some point in time. Some fields had to be unique and others had to be generated a bit differently....

March 20, 2013

No Internet Means Better Test Isolation

One day I found myself riding in a car with my family and it was a long road trip, with little to no internet and realized that my tests required internet connectivity. I was also heavily dependent upon code examples that I could find. I’ve been absolutely horrible with testing my code. I would write code, test it out in the ruby console and then push it live. It felt like I was moving fast....

February 1, 2013