# Rails Test Basics

DevFeed: [Rails Test Basics](<https://devfeed.tech/articles/rails-test-basics-28258.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2020/01/27/rails-test-basics.html>)

Author: Fuzzygroup

Published: 2020-01-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [RSpec](<https://devfeed.tech/topics/rspec.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [dockerignore-usage](<https://devfeed.tech/tags/dockerignore-usage.md>), [errors](<https://devfeed.tech/tags/errors.md>), [factorybot](<https://devfeed.tech/tags/factorybot.md>), [rails](<https://devfeed.tech/tags/rails.md>), [rspec](<https://devfeed.tech/tags/rspec.md>), [skip](<https://devfeed.tech/tags/skip.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

A practical guide to classical Rails testing for a project using standard Rails tests instead of RSpec. It covers debugging with byebug, skipping tests, running tests with Rails commands, interpreting a confusing zero-test result, using FactoryBot, and writing assertions.

## Source excerpt

More than a decade using RSpec has left me flummoxed in terms of "classical" Rails testing. I'm on a new project built using the Jumpstart application template and all the tests are standard Rails tests so here's a quick recap that I wrote, well, to force myself to step back in time and go "old school". And if you don't like my version then you should really read this. And if you are using Devise for authentication then you really must read this. Making Tests Debuggable The ability to use byebug in a testing context for breakpoints and stepping through code is utterly invaluable. Here's what you need to do for that: Add byebug into a development, test group in Gemfile. Add the line require 'byebug' to the very top of test_helper.rb How Do You Skip a Test? You put the keyword 'skip' at the top of the test that you need to skip. This is equivalent to xit in RSpec. Running Tests The very basic of testing is nothing more than test execution so to run all model tests: rails test test/models/ and to run one file rails test test/models/user_test.rb and to run everything: rails test and to run with verbose mode: rails test -v test/models and to run verbosely and fail on the first test failure: rails test -v -f test/helpers/application_helper.rb and to run just one specific test: rails test test/controllers/labels_controller_test.rb:9 Note: RSpec is very good at running the next test if the line number shifts a bit (example you put in :8 but you added a line so its actually :9). With standard rails test, you get this madness: ❯ rails test test/controllers/projects_controller_test.rb:17 Running via Spring preloader in process 95090 Run options: --seed 52687 # Running: Finished in 0.010622s, 0.0000 runs/s, 0.0000 assertions/s. 0 runs, 0 assertions, 0 failures, 0 errors, 0 skips The 0 runs, 0 assertions, 0 failures, 0 errors, 0 skips can best be interpreted as: Yo! Hoser! I don't know what to do here so I'm going to confuse you deliberately. Ha Haw! Death to Fixtures; Viva La F