As part of the selection process for the position of software engineer of the SENDU company, it is requested to generate an API, which provides a CRUD, based on the pokedexAPI.
-
Docker https://docs.docker.com/engine/install/
Alternative installation on macos
brew install orbstack
-
Run the setup script to get everything working
make setup
-
Run the server using the following command:
make serve
-
Access to rails console:
make console
-
Acess bash interactive shell:
make shell
-
To clear all the containers and volumes with database data.
make destroy
The application provides RESTful API endpoints at the following URL: `http://localhost:3000/api/v1/pokemons`. The API supports the following HTTP methods:
- POST: Create a new Pokemon
- PUT: Update an existing Pokemon
- DELETE: Delete a Pokemon
- GET (Index): Retrieve a list of all Pokemons
- GET (Show): Retrieve details of a specific Pokemon
To interact with the API seamlessly, you can use Insomnia, a powerful API testing and design tool.
Importing the API into Insomnia
- Open Insomnia and create a new workspace or open an existing one.
- Click on the '+' icon to create a new request.
- From the top menu, choose "Import"
- In the popup window, select "From File."
- Locate and choose the Insomnia_2023-11-09.json file in your repository.
- Click "Import" to load the project configuration into Insomnia.
It can also be tested through swagger...
For API documentation, Swagger is the tool of choice. To generate the HTML using Swagger, run the following command:
rake rswag:specs:swaggerize
Once generated, you can access the documentation through the following link:
You can choose any of the methods mentioned above to run commands to execute the specs
-
To run all the tests
make test
-
To run a specific test file
make shell rspec <spec_path>
-
To run a specific test within a file
make shell rspec <spec_path>:<line>