Introducci贸n

1

Pasos para construir aplicaciones en Ruby on Rails

2

Retomando nuestro proyecto

3

Instalando MongoDB

4

Migrando nuestra aplicaci贸n: componentes, librer铆as y configuraciones

5

Migrando nuestra aplicaci贸n: modelos

6

Migrando nuestra aplicaci贸n: modelos restantes y seeds

Pruebas

7

驴Qu茅 es TDD y BDD?

8

Construyendo nuestra f谩brica de documentos de prueba

9

Esteroides para tus pruebas

10

A帽adiendo pruebas de modelo

11

A帽adiendo pruebas de modelo: validaci贸n de datos

12

Finalizando las pruebas de modelo

13

A帽adiendo pruebas de peticiones

14

Creando y probando tareas de petici贸n

15

Headless browser

16

A帽adiendo pruebas de sistema: interacci贸n del sistema

17

A帽adiendo pruebas de sistema: comportamientos din谩micos

Interacci贸n din谩mica

18

Rails con caf茅

19

Selectize, esteroides para tus selects

20

Retomando los formularios anidados

21

Mejorando la asignaci贸n de participantes

Notificaciones

22

Retomando las notificaciones del proyecto

23

Introducci贸n a Service Objects

24

Construyendo prueba de servicio de notificaci贸n por correo

25

Construyendo servicio de notificaci贸n por correo

26

Introducci贸n a procesos en background y Active Job

27

Creando un Job para la notificaci贸n de correo

Ciclos de vida

28

Introducci贸n a m谩quinas de estado

29

Creando m谩quina de estados para la tarea

30

Creando servicio de gesti贸n de estados de la tarea

31

Actualizando estados usando eventos

32

Modificando estados desde la interfaz

Cierre

33

Optimizaciones: fundamentos

34

Conclusiones

You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
7 Hrs
50 Min
7 Seg

Esteroides para tus pruebas

9/34
Resources

How to set up the environment for automated testing in Rails?

In the world of software development, having an automated testing environment is crucial to ensure the proper functioning of our applications before release. Below, I'll show you how to prepare your Rails environment to implement automated tests using some essential gems and appropriate configurations.

What gems are essential for testing?

We'll start this process by integrating several gems that will be critical to our tests. First, we need to modify our Gemfile and create a new gem group exclusively for automated testing. Be sure not to use the shared group between testing and development, as these gems must be specific for this purpose.

  1. Database Cleaner: This gem is essential for keeping the database clean and in a consistent state between tests. Although MongoDB has started to implement transactional functionality, it is still advisable to use this resource to ensure that each test starts with clean and consistent data.

  2. Faker: This gem is useful for generating dummy data such as names, emails and more, without additional effort. This is especially useful when you need test data populations.

  3. Capybara: Although it will not be used immediately, Capybara will be useful when working with graphical or browser interaction tests. When we reach this point, I will explain its implementation more in depth.

How to integrate RSpec and FactoryBot?

The integration of RSpec and FactoryBot is fundamental in this process. Here's how to do it:

  1. RSpec Rails: Although RSpec is not fully tied to Rails, it is necessary to use the rspec-rails gem to properly integrate it into our project.

  2. FactoryBot: This tool allows us to create model instances quickly and automatically. You must include the factory_bot_rails gem to associate it properly in your Rails project.

How to configure the RSpec help files?

After installing these gems, the next step is to make additional configurations in the help files generated by RSpec:

  • Spec Helper: Here, you can define filters and formatting that determine the execution and reporting behavior of your tests. Be sure to enable the filter_run_when_matching :focus to run specific tests and set the default_formatter = 'doc' to get detailed results.

  • Rails Helper: In this file, import each of the installed libraries and set specific configurations, such as disabling default transactions for MongoDB and configuring helpers for FactoryBot and authentication devices.

How to optimize the use of Database Cleaner?

Database Cleaner optimization is achieved by defining specific callbacks for database cleaning before and after each test suite or individual test. In this way, you ensure that no test interferes with another, maintaining the integrity of the environment.

  • Before the test suite: Define the ORM you will use (Mongoid) and clean up the database to start with a uniform environment.

  • Before and after each test: Configure the initialization and cleanup of the database state respecting the unique context for each test.

Additional important configurations

Finally, make sure to properly configure test type inference and error handling using the following lines in your rails_helper.rb file:

  • Infer Spec Type from File Location: Facilitates the use of test type-specific methods based on the file location.

  • Filter Rails from Backtraces: Hides trace lines not relevant to the developer and related to the Rails core.

These initial configurations are essential to prepare a robust testing environment to ensure the reliability and consistency of your Rails applications. Be encouraged to continue learning and perfect your automated testing skills!

Contributions 1

Questions 1

Sort by:

Want to see more contributions, questions and answers from the community?

Esta clase deber铆a estar antes de la clase "Construyendo nuestra fabrica de documentos de prueba" para dar una mejor gu铆a a la lectura.