So, you're asked to test your application but have no idea how to begin. Or you read about TDD, RSpec, FactoryBot, Capybara, and maybe you didn't understand what they were meant for, or maybe when you tried to run them into your project nothing worked. This is a beginner guide on how to set up your environment for using these technologies. If you are not familiar with these terms, here is a brief explanation about them: It is a development technique where the tests are built before starting the real code. In this process, the tests are created based on the requirements, and the code is implemented to pass the tests. TDD (Test Driven Development): It's a Ruby written language for testing Ruby code. Yeah! This is your testing tool. A language created with Ruby in order to offer an interface to write readable tests for your project. It is an alternative for Minitest, the default Rails testing framework. This is a test example for a User model with RSpec. RSpec: RSpec.describe User, it user = User.new user.name = user.valid? expect(user.errors[ ]).to ( ) type: :model do 'name should not have less than 3 characters' do 'ab' :name include 'is too short (minimum is 3 characters)' end end Another testing tool - a library that enables browser interaction using Ruby. In other words, this one is used to simulate how a user interacts with your web application. It is combined with RSpec to create the 'feature testing' environment. Here is an example of testing with RSpec and Capybara for a 'login' page: Capybara: RSpec.feature , it fill_in , fill_in , find( ).click expect(page).to have_current_path(root_path) 'Users' type: :feature do 'are redirected to root page when login is sucessfull' do 'session_username' with: 'myusername' 'session_password' with: 'mypassword' "input[type='submit']" end end As the name says, it is a tool used to clean the database after tests. It is useful for situations where running a test creates a new object in the database that could interfere with other tests. DatabaseCleaner: It allows us to create an object or a collection of objects with predefined sets of values for our tests. What does it mean? If we have a 'User' model, we can create predefined values for different kinds of users. That means it is possible to define a 'random user' and a 'regular user' factory and use them inside your tests, without the need to declare every time. This is a really simple example of how it can be declared used inside our tests: FactoryBot: FactoryBot.define factory name { } factory sequence( ) { } do :user do 'Simple User' :user_random do :name |n| "User " #{n} end end end RSpec.describe User, it user = create( ) random_user = create( ) random_user = create( ) type: :model do '...' do :user # user.name: 'Simple User' :user_random # random_user.name: 'User 1' :user_random # random_user.name: 'User 2' end end Ok, now that you are already familiar with these terms we can move on and configure your project to use these technologies. Setting up the environment Although it seems simple, it can take some time to set up this testing environment for the first time as a beginner. Note: I'm using Rails 5. At first, let's get these babies inside our project. Open the Gemfile and make sure it has the following gems, then run 'bundle install'. group gem gem gem gem :test do # ... 'rspec-rails' 'factory_bot_rails' 'capybara' 'database_cleaner' end Now we have to generate the 'spec' folder containing the helpers for RSpec: rails rspec:install generate This command creates a file called 'rails_helper.rb' inside the spec folder. We must change this file in order to set up the RSpec environment along with FactoryBot, Capybara, and DatabaseCleaner, so the next steps are all inside the 'spec/rails_helper.rb' file. For FactoryBot, let's add this line inside the RSpec.configure block. It includes factory bot inside our tests. RSpec.configure config. FactoryBot::Syntax::Methods do |config| # ... include end To include Capybara, we need to require the gem inside our helper. So let's add this line at the beginning of the file: require 'capybara/rails' And to complete, the DatabaseCleaner. This one has some additional configs, so it has some more lines of set up. First, let's change the config 'config.use_transactional_fixtures = true' to 'false'. It will disable the native rails cleaner. RSpec.configure config.use_transactional_fixtures = do |config| # ... false # CHANGE THIS LINE TO FALSE # ... end Then, we can add the DatabaseCleaner configurations: RSpec.configure config.before( ) { DatabaseCleaner.clean_with( ) } config.before( ) { DatabaseCleaner.strategy = } config.before( , ) { DatabaseCleaner.strategy = } config.before( ) { DatabaseCleaner.start } config.after( ) { DatabaseCleaner.clean } do |config| # ... :suite :truncation :each :transaction :each js: true :truncation :each :each end And that's it! Now we are good to go with our testing. Simple right? In short, the steps are: Add the gems to Gemfile and 'bundle install'; Generate RSpec configs: 'rails generate rspec:install'; Modify 'specs/rails_helper.rb' file to include all gems in RSpec. The final 'specs/rails_helper.rb' (without the commented stuff) should be something like this: ENV[ ] = File.expand_path( , __dir_ ) abort( ) Rails.env.production? ActiveRecord::Migration.maintain_test_schema! ActiveRecord::PendingMigrationError => e puts e.to_s.strip exit RSpec.configure config.before( ) { DatabaseCleaner.clean_with( ) } config.before( ) { DatabaseCleaner.strategy = } config.before( , ) { DatabaseCleaner.strategy = } config.before( ) { DatabaseCleaner.start } config.after( ) { DatabaseCleaner.clean } config.fixture_path = config.use_transactional_fixtures = config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! config. FactoryBot::Syntax::Methods require 'spec_helper' 'RAILS_ENV' || 'test' require '../config/environment' _ 'The Rails environment is running in production mode!' if require 'rspec/rails' require 'capybara/rails' begin rescue 1 end do |config| :suite :truncation :each :transaction :each js: true :truncation :each :each " /spec/fixtures" #{ .root} : :Rails false include end And that's it, folks! I hope I could help you start testing your projects and gave you an idea about the uses of each tool. Good luck on your testing journey and happy coding!