How to change the class in FactoryBot traits

FactoryBot traits cannot use :class; a nested factory or initialize_with can build the desired subtype instead.

Spreewald 1.0.0 released

spreewald now provides a binary that lists available steps and can filter them by a search term.

Faker is now I18n aware, ships with unicorns

Faker now reads strings from locale files, which can trigger confusing translation missing errors when locale data is incomplete.

RSpec matcher "be_sorted"

Custom RSpec matcher for checking whether an array is naturally ordered; now part of Spreewald.

Configuring User Agents with Capybara + Selenium Webdriver

A while ago we were working on an application that had an entire version specially created for mobiles, such as the iPhone. This specific application was entirely tested with Capybara, Steak and Selenium Webdriver. Although the test suite wasn’t the fastest one in the world, the web application was very well tested, and to guarantee that we would also be testing the mobile version, we would have to simulate an iPhone user agent accessing the application.

But wait, you might be thinking that we are not able to change browser headers while ...

RSpec claims nil to be false

RSpec be_false matches nil, so a false check can pass unexpectedly. Use == false when the value must be exactly false.

postgres_ext: additional Rails bindings for PostgreSQL

Missing PostgreSQL types and query helpers for Rails 4.x make native array, CTE, and network-style filtering easier in ActiveRecord and Arel.

Typical .gitignore

Common ignore list for source control that keeps logs, temporary files, local databases, IDE settings, and generated assets out of git history.

VirtualBox host IP address and hostname

VirtualBox NAT guests can reach the host at 10.0.2.2; vbox.srv is the matching hostname for shared folders and host web server access.

Spreewald 1.1.0 released

Spreewald 1.1.0 removes be_true and be_false to stay compatible with RSpec 3 and Ruby 2, replacing them with == true and == false.

ApacheBench may return "Failed requests" for successful requests

ab can report successful responses as failed when later replies differ in content length from the first response. The Length counter often indicates this false positive.

Prevent the selenium webbrowser window from closing after a failed @javascript step

Failed @javascript Cucumber steps can close the Selenium browser before the page state is inspected. Keeping the window open on failure helps debug the created data.

FactoryBot: How to get the class from a factory name

Look up the model class behind a FactoryBot factory name; FactoryBot.factories.find('admin').build_class returns the associated class.

Cucumber does not find neither env.rb nor step definitions when running features in nested directories

Feature files in nested directories can stop Cucumber from loading env.rb and step definitions unless the features directory is required explicitly.

rroblak/seed_dump

Creates a db:seed:dump rake task that generates db/seeds.rb from the current database state for replayable sample data.

How to find disabled fields with Capybara

Disabled form inputs can be hard to locate in Capybara when Selenium skips them; passing disabled: true makes them searchable.

CoffeeScript

Imagine all the syntactical delights of Ruby and Haml for your JavaScript. You write in a nice language, but get normal JavaScript at runtime. All whilst having full access to 3rd-party JavaScript libraries (jQuery, PrototypeJS), debugging support (it becomes pure, readable JavaScript), existing support from test suites (it’s normal JavaScript) and growing support from various text editors (TextMate, Vim, Emacs).

Where to put custom RSpec matchers

Custom RSpec matchers fit well in spec/support/matchers, one file per matcher, and can be loaded from spec_helper.rb or Cucumber features/support/env.rb.

RSpec: be_true does not actually check if a value is true

be_true matches any truthy value, not only true; be_false likewise checks for falsiness. Use exact equality with == or eq when boolean values must be verified.

Webpacker: Disable source maps

Disabling source maps in Webpacker can reduce exposed code and simplify builds. Set config.devtool = 'none' in an environment-specific webpack config.

Obfuscating data in Rails applications for screenshots and demonstrations

Real data makes demos and screenshots look convincing, but names and values need masking to avoid exposing sensitive information. Faker can quickly replace personal details with plausible placeholders.

Article "Pricing Experiments You Might Not Know, But Can Learn From"

Pricing decisions are hard to get right, and small changes can affect revenue and customer response. Practical pricing experiments offer ideas for improving pricing strategy.

lorempixel - placeholder images for every case

Placeholder image generation for specific dimensions and topics is useful when building layouts, prototypes, or content mockups without final artwork.

Subtle Patterns Preview

Preview Subtle Patterns textures on a site without swapping images or changing CSS.