Parametrized shared example groups in RSpec
Parameterized shared examples make reusable RSpec behavior checks accept arguments and blocks, avoiding duplicated expectations across similar specs.
A solid and unobtrusive plugin for form field placeholders
jQuery plugin for placeholder text in browsers without native HTML5 support, including IE6. Skips elements that already support the placeholder attribute.
Testing state_machine callbacks without touching the database
Testing state transition callbacks without database writes requires isolating callback methods from the event itself. spec_candy offers helpers to exercise them directly.
Match strings in a given order with Cucumber and Capybara
Verify that page text appears in a specific sequence while ignoring HTML markup, using a Cucumber step for plain-text order checks.
Rails: Disable options of a select field
Rails select helpers can disable specific options by value, preventing choice of unavailable entries in forms.
Cucumber: Wait for any requests to finish before moving on to the next scenario
Selenium/Cucumber scenarios can finish before browser requests and redirects are done, leaving the session busy and breaking later steps and hooks.
ActiveRecord meets database views with scenic
Use SQL views in a Rails app without switching the schema format to SQL; Scenic adds versioned, reversible migrations and keeps view definitions in SQL files.
Beware: Nested Spreewald patiently blocks are not patient
Nested patiently blocks in Spreewald can disable retries by setting inner wait times to zero, causing flaky Cucumber/Selenium steps.
Force SSH client to use password authentication instead of public key
Password authentication can be tested by forcing SSH to skip public key login and prefer passwords. The same options also work with scp for file copies.
VNC browser disappears while typing
Typing d in a Geordi VNC browser can switch to a grey screen; pressing d again brings the browser back.
How to silence UTF-8 warnings on Rails 2.3 with Ruby 1.9
Ruby 1.9 triggers UTF-8 regexp warnings in Rails 2.3.16+ from ActiveSupport; a monkey patch in config/initializers suppresses them.
Using FactoryBot in Development
Dummy development data is faster to create by reusing FactoryBot factories than by using the UI or Rails console records. Defaults, associations, traits, and attribute overrides come along automatically.
How to find out which type of Spec you are
Runtime checks can identify the current RSpec spec type, letting shared setup run only for controller, helper, or request/response-aware examples.
How to set the default monospace font on Xfce (Xubuntu)
Applications that use the generic Monospace family ignore terminal font settings. A fontconfig override in ~/.fonts.conf can map it to a preferred font.
Change how Capybara sees or ignores hidden elements
Capybara’s default hidden-element handling affects DOM queries globally, while :visible scopes visibility checks to one lookup. Driver-specific visibility rules differ between RackTest and Selenium.
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.
Rails console tricks
Quick console shortcuts for changing receiver context, inspecting objects, making requests, using helpers, and querying schema in a Rails session.
Use byebug on Ruby 2+
debugger is unreliable on Ruby 2; byebug provides a fast, reliable debugger for Ruby 2.0.0+ using TracePoint and Debug Inspector.
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.