Using RSpec to set expectations for stdout

posted in today i learned


I’ve been working on a gem in my spare time for code coverage and one of its goals is to output coverage reports to stdout. The hope is that while running something like guard for RSpec, also having test coverage output during the red-green-refactor cycling will be useful. What I didn’t realize beforehand is that output is fully testable within RSpec. Here’s an example of ensuring a proper message is sent via puts.

Configure Puma SSL for local development on Ubuntu

posted in tutorials


Having your development environment match production helps ensure that a feature works the same in both contexts. An example of when local SSL is beneficial is whenever you are dealing with hardware specific permissions such as a webcam or microphone. This tutorial is specifically for Debian based Linux on the domain for Google Chrome but it could also be used in other contexts.

Override an ActiveRecord attribute value while using the same getter method

posted in today i learned


Overriding methods as a Rubyist is extremely natural and powerful. Recently, I did run into a circumstance where I had an ActiveRecord object with a DateTime that I needed in a specific TimeZone (based on user input). If you ever have tried to override the getter for an attribute with the same name and have been stumped, this article details one way of making it work.

Zero downtime migration from Enum to Single Table Inheritance

posted in tutorials


I’ve been refactoring quite a bit of legacy code recently. I love this kind of work because you get to architect new patterns and code pathways for future developers to use. Right past mistakes and make the future of the application just a bit brighter. My most recent refactoring involved converting an Enum based architecture to utilize Rail’s Single Table Inheritance setup. So what does it take to move from one architecture to another? Keep reading to find out strategies that I use to help keep bugs to a minimum while ensuring that end-users experience zero downtime.

How to call Pry from within a SimpleDelegator Decorator

posted in fixes


I’m by nature a kinesthetic learning or someone that learns by doing. One of the ways I learn new Ruby codebases or techniques is to dive into them and see how they work during every step of their processing. Pry is a great tool for allowing me to dig directly into code. While, really useful for debugging and understanding, one thing that has bothered me about using Pry is that it doesn’t work properly with classes that inherit from SimpleDelegator. Instead it ends up in a method_missing block. Luckily, I recently learned a great workaround for this issue which we’ll get into below.

Using attr_accesor for Class level methods

posted in tutorials


The beginning steps to writing a new class usually involve writing a quick def initialize method. The purpose of these type of methods is to setup any dependencies or configurations necessary for the object to fulfill its responsibility. With instance variables, a common paradigm is to use an attr_reader or attr_writer to read/write values. However, these methods specifically work off of instance variables.

Enable ESLint for SublimeLinter while using asdf for version management

posted in fixes


SublimeLinter is an excellent tool for linting new code quickly and efficiently. Version managers like rvm, nvm, and asdf are also great tools for smoothly switching between projects with different version requirements. Getting both SublimeLinter and version manager to play nice can sometimes be challenging. I’m going to quickly talk about the simple steps I took to getting ESLint and asdf to work with SublimeLinter below.

Deploying a jekyll blog to github pages with custom plugins and TravisCI

posted in tutorials


Deploying a new blog with Github Pages is a breeze. All you need is a new repo named after your Github username and a jekyll site on your master branch.

Github also kindly provides several whitelisted plugins for ease-of-use which can be found here. Unfortunately, some of these are a bit outdated (I’m looking at you jekyll-paginate). More bad news is that because the plugins are whitelisted you can’t use any other plugins.

We’re developers though, like a whitelist will stop us…

  • 2
  • 3
  • 4
  • 5
  • 6