Posts Tagged “ruby”
2023-03-24 Constant Doubts
Ruby's public constants often expose implementation details of the defining scope. This articles explores a simple alternative option: singleton methods. Singleton methods everywhere.
2019-01-26 Concurrent CSV exports with Ruby IO pipes
To borrow from Zawinski’s Law: Every web application expands to export CSV data (others will be replaced by ones which do).
2017-07-03 Authoring a Private Gem with Gemfury
RubyGems are a great way to share code, but not all code is for the general public. This article illustrates a (semi-automatic) way and some workflow self-discipline to streamline private Gem authoring using the Gem hosting solution »Gemfury«.
2016-07-21 Dynamically proxy images via HTTPS using Camo
Loading insecure images from within an HTTPS page causes mixed-content warnings. camo is a secure image proxy that lets you get around that. This article explains how to tie camo into your Redcarpet and html-pipeline markdown parsing to rewrite your img tags.
2016-05-20 Migrating a legacy gem to use Ruby Refinements
An old gem that's been lying around untouched since 2010 got some refactoring love. Moving away from brutally monkey patching a core class, I used this case as an academic example to illustrate how to test refinements using Test::Unit, MiniTest::Spec and RSpec.
2016-03-11 Including a Module. With Parameters!
The Ruby include statement only allows for one type of argument: the module constant(s) to include. I've found myself in a situation where I wished I could make the include statement more dynamic, like passing extra arguments that influence the module to be included. This article describes how to use a module factory to achieve exactly that.
2013-10-06 Learning Ruby with Tests (Part 2)
The second part expands on the code created in round 1 and fleshes out the existing Vehicle class. It introduces a new test helper, instance variables, explains predicates and the overrides Vehicle's initialize method.
2013-09-02 Learning Ruby with Tests (Part 1)
The first part covers a very basic class and a simple, home-made test framework, that actually doesn't deserve the name 'framework' at this stage, yet.
2011-04-20 assert_select from String
Rails provides assert_select to check for specific contents in a rendered view. We can leverage the logic to make it work out of a rendered view context.