Rails console tricks

Quick console shortcuts for changing receiver context, inspecting objects, making requests, using helpers, and querying schema in a Rails session.

factory_bot: Re-use partial factory definitions

Shared factory attributes and traits can be reused across FactoryBot definitions by extracting a trait and mixing it into multiple factories.

You can use any RSpec matcher to match arguments of method calls

RSpec method expectations can match arguments with any matcher, not just anything or hash_including, making loose argument checks more expressive.

The Easiest Way to Parse URLs with JavaScript

Parsing URLs is simpler with an <a> element than with new URL(...), and it also handles incomplete relative paths; IE11 may omit the leading slash.

Enabling view rendering for controller specs

Controller specs usually skip template rendering; integrate_views in RSpec 1 or render_views in RSpec 2 enables view rendering for specs that need it.

Testing regular expressions visually

Complex regex patterns are hard to debug by inspection; visual editors highlight matches and capture groups to make validation easier.

Rails: How to stub the env in Rails 7+

Rails 7.1 adds Rails.env.local?; stubbing Rails.env with a plain string can fail, while ActiveSupport::EnvironmentInquirer keeps environment checks working.

Testing Cookie Limits

Browser cookie storage is constrained by per-domain limits on count and total size, which can break login or tracking data when limits are exceeded.

Cucumber's table diffing does not play nice with Spreewald's `patiently do`

Cucumber::MultilineArgument::DataTable#diff! caches state, so repeated checks inside patiently do keep failing; expected_table.dup.diff! avoids the stale comparison.

Sentry Local Logging in Ruby

Local Sentry event logging helps debug error capture and background jobs without sending data to Sentry or affecting production metrics.

RSpec: Expect one of multiple matchers to match

RSpec allows chaining matchers with .or, so an expectation passes when any one matcher matches. Useful for Capybara checks across different button renderings.

Ruby: Reading and writing CSVs

Ruby can read and write CSV files with the standard CSV library, and smarter_csv makes imports more convenient when converting rows into hashes.

Know what makes your browser pant

Changing CSS properties can trigger different amounts of browser work, affecting performance when styles are updated.

How much should I refactor?

Balancing refactoring with complexity is difficult when new patterns promise cleaner, more testable Rails code. Choosing when to apply them keeps code maintainable without overengineering.

The Startup Toolkit

Practical crash courses for founding a startup, raising funding, and testing ideas before building too much.

Browsera - Automated Cross Browser Web Application Testing Service

Automated cross-browser testing finds layout problems and scripting errors on websites before users do.

Geordi hints

Quick Geordi command shortcuts for guided deployment, setup, security updates, tracker-based commits, and matching ChromeDriver installation.

Random list of ActiveSupport goodies

Handy ActiveSupport helpers add callbacks, message signing and encryption, ordered options, array wrapping, deep hash merging, whitespace squishing, and zone-aware current time.

Three quick Rails console tips

Rails console access to routing helpers, request simulation, and view helpers speeds up debugging and quick checks without leaving rails console.

RSpec 3 argument constraints use weak equality

RSpec 3 argument matching can accept broader values than strict equality, especially for classes, regexps, and ranges. Use eq or a block for exact expectations.

Bash script to list commits by Pivotal Tracker ID

Quickly list Git commits tied to one Pivotal Tracker story ID, making related changes easier to spot with a small Bash helper.

Cucumber pitfall: "Around" does not apply to your "Background" steps

Around hooks run only after Background steps, so setup or teardown placed there cannot affect background actions. Use Before and After hooks instead.

Using RSpec stubs and mocks in Cucumber

Cucumber can use RSpec doubles instead of Mocha; loading the integration in env.rb keeps stubs and mocks available after other After hooks.

How to find out if you are in Cucumber or in RSpec

Feature and spec code may need different behavior when Rails env is unavailable. Capybara.current_driver can distinguish Cucumber scenarios from RSpec examples.