Skip to main content

How to write System Tests in Rails Discussion

General • Asked by Chris Oliver

Really loving this testing series. I've been using RSpec for years but it looks like Minitest now covers a lot of the functionality that made me choose RSpec back then.

One of the things I don't like about RSpec is the amount of setup and gems required. Going with the built-in testing framework avoids all that, which is a definite win for beginners and quick-starting projects.

Be great to see your comparison of Minitest and RSpec.

How about headless browsers for system tests? I see you can switch to :headless_chrome but do you still get screenshots with that? Also, is a headless browser any faster?

Yeah, one of the reasons I choose to use Minitest over Rspec is that it's mostly just pure Ruby. You have a couple wrappers around assert, but it's really just Ruby code. Less magic means it's more reliable to reason about.

Headless browsers I do believe can still generate screenshots. I will try it to make sure. The main reason you need a headless browser is on your server, you don't have a screen, so there's no windows to actually render. It's all virtual.

My 2 cents: there's a way to display screenshots directly in iTerm2 (and likely in others terminals too):

I found it very useful to see what's going on when tests fail without having to saving or opening any file :)

iTerm is so dope, thanks for sharing that! 🙏

Great lesson.

At 11:50 you show a bootstrap modal for confirmations. How do you build that to replace the browser modal that is by default generated for a typical delete button?

That's actually using the data-confirm-modal gem to use Bootstrap instead. It's kind of hacky how it replaces the confirm method in Rails JS, but you can check out the source here.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.