Don't assert exceptions in feature specs
Capybara feature specs do not reliably catch server exceptions in another thread; request specs or visible UI assertions fit this user-level behavior better.
The numericality validator does not care about your BigDecimal precision
validates_numericality_of converts values to Float or integer, so high-precision BigDecimals can round and fail comparisons unexpectedly.
Preventing users from uploading malicious content
Uploaded HTML or SVG can execute JavaScript and steal session cookies; safer uploads rely on extension allowlists, strict CSP, attachment disposition, or octet-stream delivery.
Rails: Fixing ETags that never match
Rails default ETags often never repeat because rotating CSRF tokens and CSP nonces change response bytes, blocking cache hits and 304 responses.
ActiveRecord::Relation#merge overwrites existing conditions on the same column!
ActiveRecord::Relation#merge can overwrite conditions on the same column and return too many records; where, subselects, and, or SQL snippets preserve the intersection.
Using Capybara finder methods with arbitrary matching conditions
Capybara matchers and finders can take a Ruby block for extra DOM conditions when built-in options are not enough. Script calls inside filter blocks need a temporary wait time to avoid Selenium timeouts.
Project management best practices: Technical debt summary
Prioritizing refactoring and upgrade work is harder in larger projects; a maintained technical-debt summary helps compare effort, customer value, and developer value.
Rails: Composing an ETag from multiple records
fresh_when can combine multiple records into one ETag so associated data keeps cached pages invalidated when any rendered record changes.
Rails: Your index actions probably want strict_loading
Strict loading in index actions catches N+1 queries when views touch unpreloaded associations, causing test failures instead of hidden database hits.
Using partials in Rails views
Rails partials support locals, yield, layouts, collections, empty states, controller rendering, and cached collection rendering for reusable view markup.
HTTP headers can only transport US-ASCII characters safely
HTTP header values are limited to low-ASCII for safe transport; non-ASCII data such as Umlauts or emojis can be carried by JSON-escaping characters above 127.
How to reliably center icons vertically with text
Icons and other inline blocks can be centered against capital letters instead of the text baseline. vertical-align with font metrics or 1lh gives a reliable result.
Timecop: reset after each test
Frozen time in tests can make suites flaky when state leaks between examples. Resetting Timecop after each test or using block form prevents order-dependent failures.
Jasmine: Mocking ESM imports
Imported ESM functions are hard to spy on in Jasmine; several workarounds keep call counts testable, including wrapper objects, dependency injection, and test runners with module mocking.
Heads up: network requests `Kernel#open` are not mocked with VCR
Kernel#open and OpenURI#open_uri can still trigger real network requests in tests because VCR and WebMock do not mock them.
subscript, superscript and line-heights
<sub> and <sup> often break line height in email layouts; setting line-height: 0 with mso-line-height-rule: exactly keeps superscripts and subscripts consistent across clients.
A modern approach to SVG icons
SVG icons can be sized and colored like text without image tags, icon fonts, or extra server work by using CSS masking.
Jasmine: Creating DOM elements efficiently
Efficient ways to create DOM test fixtures for Jasmine, from HTML parsing and selector helpers to innerHTML, with readable structure and direct element references.
Jasmine: Cleaning up the DOM after each test
DOM-based Jasmine specs can leak leftover elements into later tests; using a dedicated fixture container cleared after each run keeps test state isolated.
Careful when using Time objects for generating ETags
Time values in ETag generation can lose millisecond precision, causing stale cache hits and flaky tests. Convert them to strings or numbers before combining cache keys.
Rules of thumb against flaky specs
Flaky specs often come from brittle matchers, nondeterministic record limits, and UI components that load or animate asynchronously.
Git: Restore
git restore reverses staged, unstaged, deleted, or conflicted changes with clearer intent than git checkout, and can restore files from other revisions.
Git commands to discard local changes
Removing local Git modifications is useful when work needs to be undone, parked temporarily, or cleaned from tracked and untracked files without affecting remote history.
RubyMine: Find and Replace with Regex (Capture Groups and Backreferences)
Regex find-and-replace in RubyMine uses capture groups and backreferences to rewrite quoted text, URLs, and old RSpec syntax safely.