Isolate Side Effects in Ruby
Side effects are necessary but make Ruby code harder to test and reason about; isolating them reduces coupling and keeps core logic predictable.
Standalone Cucumber Test Suite
Sometimes you inherit a non Rails or non Rack based web app such as PHP, Perl, Java / JEE, etc. I like using cucumber for functional testing so I put together this project structure to use as a starting point for testing non Ruby web based applications.
7 Fresh and Simple Ways to Test Cross-Browser Compatibility | Freelance Folder
In this article we’ve listed 7 fresh and simple tools for cross-browser compatibility testing, tools that actually make this stuff pretty easy. Not only that, but every single one of these tools can be used for free.
Celerity | Easy and fast functional test automation for web applications
Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir.
Ultimate rspec matcher to test named_scope or scoped - Web development blog
What do we expect from the custom finder? We expect that it should find assets A, B, C and should not find assets D, E, F. And sometimes the order is important: it should find A, B C with exact order.
RSpec: Executing specs by example id (or "nesting index")
Running one RSpec example without line numbers avoids fragile file-position matches when specs change. Example ids, also called nesting indexes, target the example tree directly.
RubyMine: Efficiently filtering results in the "Finder" overlay
RubyMine Finder searches can return huge result sets; file masks, directory limits, regex, and other filters narrow matches and speed up locating the right code.
Ruby: How to use global variables for a conditional debugger
Global variables can temporarily gate a Ruby debugger, avoiding repeated stops in callbacks and specs when only one execution path matters.
How to use Active Job to decouple your background processing from a gem
Background jobs in Rails can stay adapter-agnostic by using ActiveJob, making Sidekiq or Resque easy to swap without changing worker code.
Speed up large Cucumber test suites
Large Cucumber suites can become slow as they grow; deferring garbage collection during scenarios can noticeably reduce overall execution time.
How to write complex migrations in Rails
Complex Rails schema changes need SQL, embedded migration models, or adapter helpers when simple add_column and update calls cannot handle existing data safely.
Your browser might silently change setTimeout(f, 0) to setTimeout(f, 4)
Nested zero-delay timers are clamped by browsers, so repeated setTimeout(f, 0) calls can run several milliseconds late, especially in background tabs.
Enumerators in Ruby
Ruby each methods can return an enumerator when no block is given, enabling lazy iteration, chaining, and pagination-friendly data fetching.
Using the ActiveSupport::BroadcastLogger
ActiveSupport::BroadcastLogger sends one log message to multiple outputs, useful for writing Rails and Sidekiq logs to both STDOUT and files.
Integrating or upgrading makandra-rubocop
Integrating makandra-rubocop into an existing Ruby codebase often means handling many current offenses, then fixing cops incrementally without blocking development.
A simple example with a GIN index in Rails for optimizing a ILIKE query
ILIKE searches in PostgreSQL can be slow without trigram indexing; a GIN index with pg_trgm can replace sequential scans with bitmap index scans.
PostgreSQL: Be careful when creating records with specific ids
Manually assigning primary keys in PostgreSQL can leave sequences unchanged, causing duplicate-key errors on the next insert. Resetting the sequence prevents conflicts.
RSpec: Applying stubs only within a block
RSpec mocks normally persist for a spec; RSpec::Mocks.with_temporary_scope limits temporary stubs to a block and releases them afterward.
Always convert and strip user-provided images to sRGB
User-uploaded images can lose correct colors if metadata is stripped before color conversion. Converting to sRGB and reattaching the profile keeps browser rendering consistent.
Ruby: Referencing global variables with the built-in English library
Ruby’s special global variables are harder to read and can fail without require 'English', especially in Rails where the library is not loaded by default.
Ruby: How to make your ruby library configurable
Configuring a Ruby library via a block makes endpoints and similar settings easy to override without hardcoding values.