Localized external services - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS
ShamRack mounts a Rack app locally, just for your tests. It goes one further: it “mounts” it using Net::HTTP such that requests to the Rack app never hit any network.
mynyml's holygrail at master - GitHub
The Holy Grail of testing for front-end development; execute browser-less, console-based, javascript + DOM code right from within your Rails test suite.
Properly require your "spec_helper"
Different require paths for spec_helper can execute the same file multiple times in Ruby 1.8; using one consistent require 'spec_helper' avoids duplicate loading.
How to make RubyMine aware of Cucumber steps defined in gems
RubyMine can flag Cucumber steps from gems as undefined because external step definitions are not linked by default. Adding the gem under Cucumber settings restores navigation and resolution.
How to doubleclick in Selenium
Capybara tasks can be double-clicked by using Selenium-backed double_click on the matched element; plain Capybara alone does not handle double-clicks.
Use Shoulda's validate_uniqueness_of matcher correctly
validate_uniqueness_of in Shoulda needs an existing record; without it, RSpec can raise “Could not find first Keyword” during uniqueness checks.
Rails: Have different session secrets for all environments
Using the same Rails session secret in staging and production can let a cookie from one environment authenticate in another. Separate secrets per environment reduce session hijacking risk.
Exclude your staging site from Google with robots.txt and not shoot yourself in the foot
Staging sites can be kept out of Google with robots.txt while avoiding a forgotten block on launch by serving a separate exclude file on staging only.
Override e-mail recipients in ActionMailer
Our gem Mail Magnet allows you to override e-mail recipients in ActionMailer so all mails go to a given address.
This is useful for staging environments where you want to test production-like mail delivery without sending e-mails to real users.
Updated: Ruby: Don't build randomness into your factories
- Added guidance for when random values are unavoidable, recommending
FactoryBotsequences and rewinding them before each example - Added a “If you must use Faker” section showing how to set a fixed random seed and clear
Faker::UniqueGeneratorbefore each test