# Rails Console and Test Mode

DevFeed: [Rails Console and Test Mode](<https://devfeed.tech/articles/rails-console-and-test-mode-28263.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2020/02/19/rails-console-and-test-mode.html>)

Author: Fuzzygroup

Published: 2020-02-19T00: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>), [test](<https://devfeed.tech/topics/test.md>), [Testing](<https://devfeed.tech/topics/testing.md>)

Tags: [console](<https://devfeed.tech/tags/console.md>), [environment](<https://devfeed.tech/tags/environment.md>), [factorybot](<https://devfeed.tech/tags/factorybot.md>), [rails](<https://devfeed.tech/tags/rails.md>), [selenium](<https://devfeed.tech/tags/selenium.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>)

## AI overview

This short tutorial shows how to launch the Rails console in test mode with RAILS_ENV=test rails c. This lets developers inspect the test environment and work directly with FactoryBot to experiment with test factories.

## Source excerpt

This one is a short one but a good one. One really useful trick is to launch Rails console in test mode: ❯ RAILS_ENV=test rails c Running via Spring preloader in process 41705 Loading test environment (Rails 6.0.2.1) irb: warn: can't alias context from irb_context. You can check the Rails environment this way: 2.7.0 :001 > Rails.env "test" The benefit to this is that you can work directly with FactoryBot and experiment with factories: 2.7.0 :002 > project = FactoryBot.create(:project, name: "Scott's Project") FactoryBot is installed via Gemfile and locked into test environment only (which is why you need to launch Rails console in test mode): group :test do # Adds support for Capybara system testing and selenium driver gem "capybara", ">= 2.15" gem "selenium-webdriver" # Easy installation and use of web drivers to run system tests with browsers gem "webdrivers" gem 'factory_bot_rails' #gem 'database_cleaner' # gem 'shoulda' # gem 'shoulda-matchers' end