---
title: "Rails tests: How to properly test Ruby on Rails apps?"
description: Do you realize how the testing process affects of the app? We present our article in which we discussed Rails testing from the perspective of RoR apps.
image: https://blog-hubspot.railwaymen.org/hubfs/rails%20tests%20(1).jpg
---

[![Railwaymen](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/Railwaymen_September2018/Images/logo_bia%C5%82e.png?width=260&height=70&name=logo_bia%C5%82e.png "Railwaymen")](https://railwaymen.org/)

- [Blog Main Page](https://blog-hubspot.railwaymen.org)
- [About Us](https://railwaymen.org/about-us)
- [Our Work](https://railwaymen.org/case-studies)
- [FAQ](https://railwaymen.org/our-ai-knowledge-base)
- [Contact Us](https://railwaymen.org/contact-us)

![rails tests: how to properly test ruby on rails apps?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/rails%20tests%20(1).jpg?width=1320&name=rails%20tests%20(1).jpg)

[Business and Technology](https://blog-hubspot.railwaymen.org/tag/business-and-technology)

# Rails tests: How to properly test Ruby on Rails apps?

- [Przemysław Łata](https://blog-hubspot.railwaymen.org/author/przemyslaw-lata)
- [11th August '22](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps)

As you probably know, just creating an app is not the last step before giving it to users. Before you decide to officially launch your Ruby on Rails app it's still worth checking it completely. For this purpose, it may be necessary to conduct functional tests, which will indicate which elements need to be refined. With our help, you'll learn how to properly execute all the tests to make your Rails application fully functional from a technical point of view and user-friendly at the same time.

![Rails test](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/0f95792e-9364-4702-b55b-b41e2ddaa8f0%20(1).jpg?width=447&height=298&name=0f95792e-9364-4702-b55b-b41e2ddaa8f0%20(1).jpg)

### Table of Contents:

[1. What is the responsibility of the Rails test?](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pa)

[2. What is the system testing in Rails?](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pb)

[3. Types of tests in Ruby on Rails.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pc)

[3.1. Unit testing.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pd)

[3.2. Functional testing.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pe)

[3.3. Integration testing.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pf)

[3.4. Performance testing.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pg)

[4. Concept of The Test Pyramid.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#ph)

[5. Types of testing framework tools (RSpec vs Capybara).](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pi)

[6. What Do Rails tests look like in Railwaymen?](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pj)

[7. The test environment from our QA perspective.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pk)

[7.1. Manual tests.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pl)

[7.2. Test automation.](https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps#pm)

 

## What is the responsibility of the Rails test?

Prior to moving on to the various testing models, it will be necessary to complete the knowledge of the process itself. Testing a **Rails application** is relatively simple. It begins with the development of the **test code skeleton**, which is created when the models and controllers are created. Moreover, **code refactoring** does not affect the ability to validate the code. **The Rails test** can mirror browser behavior. This way, you can check the responsiveness of your application without having to do it through the browser.

## What is the system testing in Rails?

**System testing** is nothing more than a thorough verification of the integrated software. Its purpose is to **test Rails applications** under conditions similar to user behavior. You might think, well, okay, but why using **system tests** when I can run the program manually after writing it and make any corrections manually? This approach may work, but in case you have a small application. At some point, your **Rails project** grows so large that you are not able to keep track of all the features. Then [system testing](https://blog-hubspot.railwaymen.org/how-to-choose-the-best-tools-for-qa-software-testing) becomes essential to avoid regression.

The mission of **rails testing** is to simulate as close as possible user behavior towards the application. As a result, the application, when implemented, is bug-free and doesn't cause any problems for users. With a **dedicated test database**, you can automate checking your tool every time.

![system test](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/c71e0528-9c1c-44f7-afd3-9429fac84917.jpg?width=500&height=334&name=c71e0528-9c1c-44f7-afd3-9429fac84917.jpg)

## Types of tests in Ruby on Rails

When **testing framework Ruby on Rails**, we are faced with 4 types of tests:

- unit tests
- functional tests
- integration tests
- performance tests.

### Unit testing

**Unit testing** is the most widely used automated testing method. **Unit tests** involve testing a piece of code based on a test method. After running the selected particular **test method** and setting certain parameters, it is checked whether the result of such a method matches the assumptions. A characteristic feature is that this type of testing is performed very quickly. That's why, for [Rails applications](https://blog-hubspot.railwaymen.org/ruby-on-rails-development-services) such tests should be the most frequently performed.

### Functional testing

**Functional test** is slightly more complicated than the unit test described earlier. The difference can be seen in the fact that there is more going on in each of these tests than in the **unit tests**. What's more, the role of **functional testing** is to check whether multiple components of the application are working properly.

### Integration testing

**Integration tests** are responsible for checking applications from the outside. Their characteristic feature is the consideration of multiple controllers that are part of the user flow. Each **integration test** brings great value to the entire project, because it rests on the role of efficiency not of a part, but of the entire application.

### Performance testing

**Performance testing** is designed to obtain a specific set of metrics with which actions can be made to improve the application code. **Performance tests** are also responsible for ensuring that users do not spend too much time waiting for a page to load. It's through them that you'll find out what's causing the application's speed and memory problems.

![write efficient tests](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/bb555ac4-df71-404c-b53a-63ba1cd472c1.jpg?width=500&height=333&name=bb555ac4-df71-404c-b53a-63ba1cd472c1.jpg)

## Concept of The Test Pyramid

Each of us has probably encountered more than once the [concept of Maslow's hierarchy](https://www.simplypsychology.org/maslow.html) of needs presented in the form of a pyramid. A similar pyramid is present in **testing Rails applications**. However, in the **test pyramid** there are fewer floors. The model of the pyramid described above originated with Mike Cohn, who described the concept in his book "Succeeding with Agile".

### Step 1: Unit tests

According to the author, the pyramid should illustrate the developer's chosen test suite. The basis in his considerations are **unit tests**. There should be many of them with a low level of sophistication. When creating unit tests, one should remember to avoid the most common mistakes. These include testing trivial code, **tautological tests** and tying the **test suite** to the implementation.

### Step 2: Functional tests

The next floor of the pyramid should be **rails functional tests** for controllers. Essential at this stage, according to Cohn, are controller actions and validations, as well as their compatibility with the database. What should be tested are **network request**, **user redirection**, **user authentication**, **presentation of relevant messages and information to the user**.

### Step 3: System tests

The pinnacle of the concept belongs to **system testing**. These are responsible for interacting with the application through the browser. As a result through system tests, the **user flow** can be simulated. Anything that requires the user to interact through a click and forms to fill out needs to be tested accordingly.

## **Types of testing framework tools (RSpec vs Capybara)**

In **Rails testing terminology**, the most important thing is not the tools themselves but the testing principles. Nevertheless, it is useful to have knowledge of basic frameworks that facilitate the **testing process**. Among the most common framework tools are **RSpec and Capybara**.

**RSpec** is responsible for providing the appropriate structure for writing tests and the ability to run them. This is the most popular solution for commercial projects implemented in **Rails testing code**. In the case of Capybara, there is a library that uses **Ruby** to wrap the driver. This meets all the needs of simulating user keystrokes using convenient **Ruby test methods**.

 

![test method stops](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/72d3b3ea-38fa-4579-943c-de469c172893%20(1).jpg?width=500&height=333&name=72d3b3ea-38fa-4579-943c-de469c172893%20(1).jpg)

## **What Do Rails tests look like in Railwaymen?**

Testing is an essential part of developing the **Ruby on Rails app** at Railwaymen. Our base **testing tool** is **RSpec**, which we have been using in our work for many years. Our established requirement is **100% code coverage**, so we insist among developers that they use the capabilities of this **testing framework**. In this way, we also reduce the additional cost for each new person joining the project.

Our default factory library is factory bot. We use it because it has a lot of capabilities and, used properly, provides the necessary performance. On the other hand, in terms of **mocking & stubbing**, there is nothing better for us than the elements assigned to **RSpec**. Thanks to the variety of cases that occur in this **test framework**, there is no need to add more libraries.

In **Rails tests** all external **HTTP requests** need to be disabled all the time. Every HTTP request must be stubbed either by stubbing the request itself or the methods that are responsible for executing it. However, when creating an integration with an **external API**, it is important to check that the **code executes** the correct requests with the correct parameters and headers. For this, we at **Railwaymen** use **Webmock**, which can easily block all requests in tests and provides a very simple **DSL** for **stubbing and mocking**. It also writes out all **external HTTP** requests along with information on how to mock it. 

## **The test environment from our QA perspective**

### **Manual tests**

For the [Quality Assurance team](https://blog-hubspot.railwaymen.org/why-quality-assurance-is-important-8-benefits-that-qa-brings-to-your-project) at Railwaymen, there are quite a few issues strictly related to **testing Ruby on [Rails applications](https://blog-hubspot.railwaymen.org/best-ways-to-scale-ror-app)**. Of the **manual types of tests** listed above, **functional tests and integration tests** are the most common with us.

In addition, when **testing the applications** we create, we use the possibilities offered by **API tests**. In the course of **building Rails API** similarly, we use [Test Driven Development](https://blog-hubspot.railwaymen.org/test-driven-development-tdd-reducing-costs-software-development), which significantly facilitates our work on the code.

The last type of **manual tests** that we use is **accteptance tests**. During this process, our **QA specialists** check to what extent the application coincides with **user expectations**. In case of any irregularities during this process, the software is corrected and not sent to production.

### **Test automation**

Additionally to **manual testing**, we also use automation. For this purpose, we use two automation tools **Selenium** and **Cucumber**. The first one is a **web browser automation tool**. It is used to **automatically test** the user interface. Selenium is also responsible for performing **user interface tests**. While **Cucumber** is a behavior-driven development tool that can be used with **Selenium**. It is typically used by non-technical teams and used to perform **acceptance testing**. An interesting fact is that **Cucumber** was originally created in Ruby. However, over the years the framework has evolved so much that it is now supported by many programming languages.

If you want to see how the testing process affects the final outcome of the project, then we encourage you to visit our Case Studies. There you will find many of our solutions supported by proper testing.

[CHECK OUT OUR CASE STUDIES](https://railwaymen.org/case-studies)

 

[Business and Technology](https://blog-hubspot.railwaymen.org/tag/business-and-technology) [Railwaymen](https://blog-hubspot.railwaymen.org/tag/railwaymen)

- Share:
- <https://twitter.com/share?text=Rails%20tests:%20How%20to%20properly%20test%20Ruby%20on%20Rails%20apps?&url=https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps>
- <http://www.facebook.com/sharer/sharer.php?u=https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps>
- <http://www.reddit.com/submit?url=https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps&title=Rails%20tests:%20How%20to%20properly%20test%20Ruby%20on%20Rails%20apps>
- <https://www.pinterest.com/pin/create/button/?url=https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps>
- <http://www.linkedin.com/shareArticle?mini=true&url=https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps>

![Przemysław Łata](https://blog-hubspot.railwaymen.org/hubfs/przemek%20(1)%20(1)%20(2)%20(1).jpg)

Author

#### [Przemysław Łata](https://blog-hubspot.railwaymen.org/author/przemyslaw-lata)

- <https://www.linkedin.com/in/przemyslawlata/>

 Przemek (Content & SM Specialist) likes to learn about marketing. He has experience in content marketing, SEO and event organisation.

##### [![best ways to monetize mobile apps (app monetization models)](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/ways%20to%20monetize%20mobile%20apps.webp?width=305&name=ways%20to%20monetize%20mobile%20apps.webp) Related Article Business and Technology Best ways to monetize mobile apps (App monetization models) 9 min read Full Article](https://blog-hubspot.railwaymen.org/best-ways-to-monetize-your-mobile-app)

##### [![how did we reduce discovering customer needs from weeks to 72 hours?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/BLOG%20Cover%20-%20How%20did%20we%20reduce%20the%20process%20of%20discovering%20customer%20needs%20from%20weeks%20to%2072%20hours.jpg?width=305&name=BLOG%20Cover%20-%20How%20did%20we%20reduce%20the%20process%20of%20discovering%20customer%20needs%20from%20weeks%20to%2072%20hours.jpg) Related Article Business and Technology How did we reduce discovering customer needs from weeks to 72 hours? 6 min read Full Article](https://blog-hubspot.railwaymen.org/how-did-railwaymen-reduce-discovering-customer-needs)

##### [![why modern epos systems are redefining restaurant profitability?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/epos%20device%20for%20restaurant%20(1).jpg?width=305&name=epos%20device%20for%20restaurant%20(1).jpg) Related Article Business and Technology Why Modern ePOS Systems Are Redefining Restaurant Profitability? 8 min read Full Article](https://blog-hubspot.railwaymen.org/why-epos-systems-are-redefining-restaurant-profitability)

## [![what is sinatra ruby? how to build applications using sinatra?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/pexels-lara-wehbe-10923806.jpg?width=1905&height=510&name=pexels-lara-wehbe-10923806.jpg) Next Post --- What is Sinatra Ruby? How to build applications using Sinatra? Business and Technology](https://blog-hubspot.railwaymen.org/what-is-sinatra-ruby)

[![Railwaymen Logo](https://railwaymen.org/assets/svgs/rwm-logo-white-ae5182ba602bcbf3713fd6bb3a5288956e484b62ddf1c647e53f2fb72644913d.svg)](https://railwaymen.org)

 Railwaymen Sp. z o.o.   
 Email: info@railwaymen.org   
 NIP: 6793065841

[![European Funds Smart Growth](https://railwaymen.org/assets/icons/logos/unia-98bb8c7ed12fa79f2ddbe0e00b222213700102dba79748d59f43a304d9803de6.png)](https://railwaymen.org/grants)

[Estimate Project](https://railwaymen.org/estimate-project) [Newsletter Subscribe](https://learn.railwaymen.org/newsletter)

- <https://www.linkedin.com/company/railwaymen>
- <https://www.facebook.com/railwaymen.software.development>
- <https://www.youtube.com/channel/UCu5v1NuohjsTZXGV4K60KWA>
- <https://www.instagram.com/railwaymen_org>
- <https://twitter.com/Railwaymen_org>
- <https://dribbble.com/Railwaymen_org>
- <https://www.behance.net/railwaymen>

##### Company

- [Services](https://railwaymen.org/services)
- [Our Work](https://railwaymen.org/case-studies)
- [About us](https://railwaymen.org/about-us)
- [Blog](https://blog.railwaymen.org)
- [Career](https://railwaymen.org/careers)
- [Personal Data Protection](https://railwaymen.org/personal-data-protection)
- [Cookies Policy](https://railwaymen.org/docs/Cookie_Policy.pdf)
- Cookie Settings

##### Services

- [Web Development](https://railwaymen.org/services/web-development)
- [Mobile Development](https://railwaymen.org/services/mobile-development)
- [Product Design](https://railwaymen.org/services/product-design)
- [Discovery Phase](https://railwaymen.org/services/discovery-phase)
- [MVP Development](https://railwaymen.org/services/mvp-development)
- [Digital Transformation](https://railwaymen.org/services/digital-transformation)
- [Social Networking Software](https://railwaymen.org/services/social-networking-software)
- [Restaurant App Development](https://railwaymen.org/services/restaurant-app-development)
- [Construction Sofware Development](https://railwaymen.org/services/construction-software-development)
- [Custom Marketing Software Development](https://railwaymen.org/services/custom-marketing-software-development)
- [FinTech App Development](https://railwaymen.org/services/fintech-development)

##### Our Experts Must - Reads

- [Is Ruby on Rails Dead in 2025?](https://blog.railwaymen.org/is-ruby-on-rails-dead)
- [How to Start an App Development Project? \[Checklist\]](https://blog.railwaymen.org/checklist-what-you-have-to-do-to-start-the-app-development-project)
- [How to Build an MVP? \[5 Steps\]](https://blog.railwaymen.org/how-to-build-an-mvp)
- [How Long Does it Take to Make An App in 2025?](https://blog.railwaymen.org/how-long-does-it-take-to-make-an-app)
- [Agile Discovery Phase: a Must Have for Your Business](https://blog.railwaymen.org/why-a-discovery-phase-is-a-must-have-for-your-project)
- [Railwaymen App Development Cost Breakdown - How Much do We Charge and Why?](https://blog.railwaymen.org/app-development-cost-breakdown)
- [FAQ: Web & Mobile Development With Us Explained](https://blog.railwaymen.org/railwaymen-faq-web-and-mobile-development-with-us-explained)

 Awards

[![Clutch Recognition Best B2B Companies Global](https://railwaymen.org/assets/awards/Top_B2B_Companies_Global_2018-5d1c8e5358737540e214ce8d51e450fe06ac4be35a0a220c0c2ccfa912787879.png)](https://clutch.co/profile/railwaymen)[![Clutch Recognition Best Ruby on Rails Developers](https://railwaymen.org/assets/awards/ClutchAward2021-013bdba335eecb6eb59319b0475d099899bbb2fa50e4596186ea2126d5b606af.png)](https://clutch.co/press-releases/recognizes-top-performing-development-companies-poland-2021)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperPoland_2022-d094b46bd3ce96c9355d21d0c6a05bc4f5959ec255f6815af8797c0a938a6b9e.png)](https://clutch.co/profile/railwaymen)[![Clutch Top React Native Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopReactNativePoland_2022-a50094d73ac73fec5c868c5544048db746c9a086fcbe9e7dcf3644875c47762c.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopRubyOnRailsPoland_2022-dc90eec21384445755158dd53914b6e3ef947e75cfe6dba521822c73bd64b789.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Software Developer Fintech 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperFintech_2022-ba75658f45c04d38d0fa4f9dcbfc78e2982b62222d681d6dc3f2f40fe2cafc9b.png)](https://clutch.co/profile/railwaymen)[![Clutch B2B Services 2022](https://railwaymen.org/assets/awards/Best-PerformingB2B2022-4a7057260a703088e644083b31320fe6fdafbfe3491eadf7e9a711fa9e3f9174.png)](https://clutch.co/profile/railwaymen)

[![Clutch Recognition Best App Development Company](https://railwaymen.org/assets/awards/TheClutch1000-a5cd5e3433659ee45539838fa945002f147b6ed9065166f8ba9ff56d216173eb.png)](https://blog.railwaymen.org/railwaymen-named-global-leaders-top-10-ruby-on-rails-developers-2018?_gl=1*1lggq91*_gcl_au*MTY4NzY2MDQ5Mi4xNzMxNDAxMDg4*_ga*MTY1MzUxNjI1Ni4xNzMxNDAxMDg4*_ga_1TW68M8Z6C*MTczMjcwMDE4Ny4xNi4xLjE3MzI3MDExMzYuMzIuMC4w)[![Top Software Development Company](https://railwaymen.org/assets/awards/Custom-Software-Development-Companies-1c56b8d73fbc48c21514311021c65f85a53cd955a3f910a9c2347a6c4a934b0f.png)](https://www.softwareworld.co/top-custom-software-development-companies/)[![Hire elite software development vendors at Pangea](https://railwaymen.org/assets/awards/Pangea-3db009da8ad6d19dfdafc66c51d16928730a715c3195776579bff5e0df4c13d4.png)](https://www.pangea.ai/vendors/railwaymen/)[![GoodFirms Badge](https://railwaymen.org/assets/awards/goodfirms-6880d7b6b80ee00d7189656a8236466571c5f94f146a8d42f5421d85f53b05df.svg)](https://www.goodfirms.co/company/railwaymen)[![Digital Knights](https://railwaymen.org/assets/awards/dk-8e9cb01c4fb52cd6dd812212e5d6925772aa6399c71d47387e3f8a8d5d58ac59.svg)](https://www.digitalknights.co/)

Railwaymen locations

- Kraków
  
  Na Zjeździe 11, 30-527
- San Francisco
  
   Silicon Valley Acceleration Center. 180 Sansome Street

 You can change your cookie settings at any time Close and don't show again

© 2026 Railwaymen

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Przemysław Łata",
    "url" : "https://blog-hubspot.railwaymen.org/author/przemyslaw-lata"
  },
  "dateModified" : "2025-04-14T12:14:26.771Z",
  "datePublished" : "2022-08-11T12:26:48.000Z",
  "headline" : "Rails tests: How to properly test Ruby on Rails apps?",
  "image" : [ "https://blog-hubspot.railwaymen.org/hubfs/rails%20tests%20(1).jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog-hubspot.railwaymen.org/rails-tests-ruby-on-rails-apps",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog-hubspot.railwaymen.org/hubfs/new%20website/rwm%20logotype.png"
    },
    "name" : "Railwaymen Sp. z o.o."
  }
}
```