Monthly Archives: June 2015

Relocation notice


The Gemfile blog will continue life at If you hurry, you might be the first one to read my brand-new article Empowering Null Objects in a Rails Application.

See you there!


Selective stubbing of method calls in RSpec

While building a simple API in Rails, I had the following method in my User model that needed to be tested:

def generate_auth_token!
  loop do
    self.auth_token = Devise.friendly_token
    break unless self.class.exists?(auth_token: auth_token)

The method uses Devise’s friendly_token method to generate an authentication token for a new user record. After calling the method once, the loop checks whether a user record with the same auth token already exists. If the answer is positive, the method goes for a second try; otherwise it breaks out of the loop, mission accomplished. Continue reading

Tagged , ,

€ £ $ ¥ ₽

Thanks to Stack Overflow’s annual survey, we now have this gem (pun intended) of data:

Screen Shot 2015-06-11 at 9.38.02 AMScreen Shot 2015-06-11 at 9.39.20 AM

Is this as absurd as it appears? Let’s take a closer look. Continue reading

Tagged , , , , , ,