Rails: Testing file downloads with request specs

Posted About 1 month ago by Julian.

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

Best practices: Writing a Rails script (and how to test it)

Posted 3 months ago by Dominik Schöler.

A Rails script lives in lib/scripts and is run with bin/rails runner lib/scripts/.... They are a simple tool to perform...

Rails: Testing the number of database queries

Posted 3 months ago by Dominik Schöler.
github.com

There are a few tools to combat the dreaded n+1 queries. The bullet gem notifies you of missing eager...

Maintaining custom application tasks in Rails

Posted 3 months ago by Emanuel.

Here are some hints on best practices to maintain your tasks in larger projects. Rake Tasks vs. Scripts

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.

Lightning Talk: Coverage based Test Case Prioritization in Ruby on Rails

Posted 7 months ago by Felix Eschey.
github.com

For my computer science bachelor's thesis I programmed and evaluated a CLI Test Case Prioritization (TCP) tool for makandra...

Node: How to run a globally installed package with npx

Posted 8 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 8 months ago by Felix Eschey.

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

Chromedriver: Connect local chromedriver with docker

Posted 10 months ago by Emanuel.

Debugging your integration tests, that run a headless Chrome inside a docker image, is tricky. In many cases you can...

Rails: How to test the parsed response body

Posted About 1 year ago by Emanuel.

Testing your responses in Rails allows to parse the body depending on the response MIME type with parsed_body.

Jasmine: Creating DOM elements efficiently

Posted Over 1 year ago by Henning Koch.

Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common...

JavaScript: Testing whether the browser is online or offline

Posted Almost 2 years ago by Henning Koch.

You can use the code below to check whether the browser can make connections to the current site: await isOnline...

Capybara: Most okayest helper to download and inspect files

Posted Almost 2 years ago by Henning Koch.

Testing file download links in an end-to-end test can be painful, especially with Selenium. The attached download_helpers.rb provides...

RSpec: How to turn off partial double verification temporarily

Posted About 2 years ago by Emanuel.

While verifying doubles in RSpec is a good default, it is limited in the amount of methods it actually is...

Jasmine: Testing if two arrays contain the same elements

Posted About 2 years ago by Henning Koch.

When the order matters: expect(array1).toEqual(array2) Regardless of order: expect(array1).toEqual(jasmine.arrayWithExactContents(array2)) Ignoring extra elements:

RSpec: You can super into parent "let" definitions

Posted About 2 years ago by Arne Hartherz.

RSpec's let allows you to super into "outside" definitions, in parent contexts. Example: describe '#save' do subject { described_class.new(attributes...

Using feature flags to stabilize flaky E2E tests

Posted Over 2 years ago by Henning Koch.

A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs...

Accessing JavaScript objects from Capybara/Selenium

Posted Almost 3 years ago by Dominic Beger.

When testing JavaScript functionality in Selenium (E2E), you may need to access a class or function inside of a evaluate...

Online tool to convert tables between different formats

Posted About 3 years ago.
tableconvert.com

https://tableconvert.com/ is an online tool to convert tables between different formats (e.g. json, markdown, csv).

Mixed Content Examples

Posted About 3 years ago by Dominik Schöler.
mixedcontentexamples.com

The pages […] allow you to see different types of mixed content and test how they behave in your browser. The...

How to test inside iframes with cucumber / capybara

Posted Over 3 years ago.

When testing with Cucumber / Caypbara, iframes are ignored, so you can't interact with them. To interact with your iframe...

FactoryBot: Traits for enums

Posted Almost 4 years ago by Florian Leinsinger.
github.com

FactoryBot allows to create traits from Enums since version 6.0.0 The automatic definition of traits for Active Record enum attributes...

Select2 alternatives without jQuery

Posted Almost 4 years ago by Henning Koch.

Select2 is a fantastic library for advanced dropdown boxes, but it depends on jQuery. Alternatives Tom Select

Testing for XSS in Markdown Fields

Posted Almost 4 years ago.
github.com

If you render markdown from user input, an attacker might be able to use this to inject javascript code into...