Rails: Testing file downloads with request specs

Posted 4 days ago by Julian.

tl;dr Prefer request specs over end-to-end tests (Capybara) to joyfully test file downloads! Why? Testing file downloads

List of handy Ruby scripts to transcode different file types (often by using GPT)

Posted 5 days ago by Michael Leimstädtner.

It's 2024 and we have tools like ffmpeg, imagemagick and GPT readily available. With them, it's easy to...

Virtual scrolling: A solution for scrolling wide content on desktops

Posted 18 days ago by Tobias Kraze.

I recently built a screen with a very high and wide table in the center. This posed some challenges:

Bash: How to grep logs for a pattern and expand it to the full request

Posted About 2 months ago by Emanuel.

I, [2024-01-21T06:22:17.484221 #2698200] INFO -- : [4cdad7a4-8617-4bc9-84e9-c40364eea2e4] test

Unpoly 3.7.1, 3.7.2 and 3.7.3 released

Posted 2 months ago by Henning Koch.
unpoly.com

Version 3.7.0 broke some things in complex forms. Sorry for that. Concurrent user input is hard. 3.7.1 This change fixes...

Browser debugging tricks

Posted 2 months ago by Dominik Schöler.
alan.norbauer.com

A list of clever debugging tricks. TOC: Advanced Conditional Breakpoints monitor() class Calls Call and Debug a Function Pause Execution...

open-next-failure: An alias to speed up test debugging

Posted 3 months ago by Michael Leimstädtner.

Getting an entire test suite green can be a tedious task which involves frequent switches between the CLI that is...

Livereload + esbuild

Posted 3 months ago by Tobias Kraze.

Getting CSS (and JS) live reloading to work in a esbuild / Rails project is a bit of a hassle, but...

How to (and how not to) design REST APIs · stickfigure/blog Wiki

Posted 4 months ago by Henning Koch.
github.com

In my career, I have consumed hundreds of REST APIs and produced dozens. Since I often see the same mistakes...

A reasonable default CSP for Rails projects

Posted 4 months ago by Tobias Kraze.

Every modern Rails app should have a Content Security Policy enabled. Very compatible default The following "default" is a minimal...

How to: Upgrade CarrierWave to 3.x

Posted 4 months ago by Dominic Beger.

While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic...

Zeitwerk: How to collapse folders in Rails

Posted 4 months ago by Niklas Hä..

All direct child directories of app are automatically added to the eager- and autoload paths. They do NOT create a...

Heads Up: Selenium 4 uses a binary to determine the chromedriver

Posted 5 months ago by Florian Leinsinger.
selenium.dev

I recently stumbled over a problem that my feature tests broke in CI because of a mismatching chromedriver version.

Using Ruby's Method objects for inspecting methods

Posted 5 months ago by Felix Eschey.
ruby-doc.org

Do you remember finding where a method is defined? I recently learned from a senior colleague that Method objects are...

Git restore vs. reset for reverting previous revisions

Posted 6 months ago by Felix Eschey.

The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the...

redirect_to and redirect

Posted 6 months ago by Niklas Hä..

There are multiple ways to redirect URLs to a different URL in Rails, and they differ in small but important...

Do not pass params directly into url_for or URL helpers

Posted 6 months ago by Arne Hartherz.

Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.

Do not use "permit!" for params

Posted 6 months ago by Arne Hartherz.

Rails' Strong Parameters enable you to allow only specific values from request params to e.g. avoid mass assignment.

Node: How to run a globally installed package with npx

Posted 7 months ago by Emanuel.

You can tell npm to install a package globally with npm -g install @puppeteer/browsers. However, it seems that its not...

RSpec: How to write isolated specs with cookies

Posted 7 months ago by Felix Eschey.

Rails offers several methods to manage three types of different cookies along with a session storage for cookies. These...

Git: Splitting up changes into several commits

Posted 8 months ago by Felix Eschey.

Splitting up commits makes the process of reviewing often easier, since you can create several merge requests or review every...

Code splitting in esbuild: Caveats and setup

Posted 8 months ago by Henning Koch.

TL;DR Still has caveats. Code splitting is a feature of JavaScript bundlers that can keep huge libraries out of...

Don't assert exceptions in feature specs

Posted 8 months ago by Michael Leimstädtner.

As we are slowly switching from Cucumber scenarios to RSpec feature specs, you might be tempted to write assertions like...

Byebug cheatsheet

Posted 9 months ago by Felix Eschey.
gist.github.com

Context and further resources Even though you can get 90% of debugging done with up to 5 basic byebug commands...