RSpec expects pending tests to fail
Pending RSpec examples need a failing body; otherwise a passing pending example is treated as a failure. Omit the body, add fail, or skip with xit/xdescribe.
Heads up! Years are always floats in Rails < 4
1.year returns a Float in Rails < 4 and can break code that expects an integer duration; Rails 4 uses ActiveSupport::Duration instead.
Centering with CSS vertically and horizontally (all options overview)
CSS centering is awkward because each method has trade-offs in browser support, sizing, and layout constraints. Two guides help choose the best alignment approach for a given use case.
Think twice before using application names in your variables and methods
Using application or provider names in variable and method names makes code brittle during replacements and extensions; abstract, reusable names reduce renaming and adaptation work.
Katapult 0.4.0 released
Katapult 0.4.0 adds application-model associations and can generate a project README for Rails-style project scaffolding.
Cucumber: How to avoid VCR errors for unused requests in pending tests
Pending Cucumber steps can fail when VCR cassettes contain unused HTTP interactions; @allow_unused_http_interactions can be enabled only for pending features.
Katapult 0.3.0 released
Katapult 0.3.0 adds Rails 5.1.4 and Ruby 2.5.0 support, a new Bootstrap-based design, Webpacker, and workflow and test improvements.
Ruby: Using all? with empty collection
all? returns true on empty collections, which can accidentally match missing associations and lead to unwanted deletions or other false positives.
How to mirror a git repo to a new remote
Move a repository between Git hosts without losing branches, tags, or untracked commits. Mirroring the old remote to the new one keeps the destination in sync.
Capybara: A step for finding images with filename and extension
Capybara step for checking an image by matching part of its src against a filename and extension during browser tests.
How to debug Rails autoloading
Rails constant loading can fail silently in development, especially with threaded code. Logging ActiveSupport::Dependencies helps trace autoloader behavior and diagnose hangs.
PostgreSQL: How to UPDATE multiple attributes with multiple joins
Updating several columns from multiple related tables in PostgreSQL can be awkward without the right UPDATE ... FROM pattern and join conditions.
Sprites with Compass
CSS sprites can reduce image requests by bundling small backgrounds into one sprite; Compass and compass-rails automate sprite generation in Rails apps.
How to query PostgreSQL's json fields from Rails
PostgreSQL json fields store flexible data, but Rails lacks built-in querying sugar. Matching nested values requires manual SQL operators and text extraction.
Font Awesome 5 migration guide
Font Awesome 5 changes icon names and adds fab, far, and fas prefixes; a JavaScript shim can preserve v4 names during migration.
RSpec: How to check that an ActiveRecord relation contains exactly these elements
contain_exactly checks whether an ActiveRecord relation has the expected records, and splatting an AssociationRelation makes the matcher work as intended.
jQuery: How to attach an event handler only once
Prevent duplicate event callbacks in jQuery by using .one() for single-fire handlers or off()/on() with the same function reference.
Ruby: control flow with throw and catch
throw and catch provide a way to exit multiple nested loops early when a result is found, complementing Ruby’s return, break and next flow control.
Form letters with LibreOffice Writer
Create mass letters in LibreOffice Writer by using a spreadsheet as an address source and inserting mail-merge fields; the built-in wizard is unreliable and may crash.
Error during Rails 5 upgrade: Environment data not found in the schema
Rails 5 upgrade can fail when the database schema lacks configured environment data, especially during parallel test database migration.
Remember: LoDash syntax is a bit different from UnderscoreJS
LoDash chaining differs from UnderscoreJS: _ methods may return wrapper objects, and value() ends a chain. The compatibility build can mimic Underscore behavior.
How to find and replace empty cells in Libre Office Calc
Blank spreadsheet cells in LibreOffice Calc are hard to target with normal search; regular expressions let Find & Replace match them reliably.
How to use cookies with curl
Curl sends and stores no cookies by default; -c and -b let you save, reload, or manually supply them for repeated requests.