Important
Change the Project Name
Search about rails_api_boilerplate and replace it where it"s needed.
Don"t forget about the folder name too. ;)
$ ./bin/setupImportant
Don"t forget to follow the .env_example to build your .env.
$ rails s (default port number: 3000)
$ rails s -p <port number>Try it:
curl localhost:3000$ bundle exec rspec spec/<path to file>_spec.rb (run a spec)
$ ./bin/test (run the test suite)Important
The test suite script needs to have execution permission. To give it use this:
$ chmod +x bin/testCoverage ...% is below the expected minimum coverage (100.00%, why not?!).
Run the test suite and open the coverage index file
$ open coverage/index.htmlAnd the security verification report
$ open coverage/brakeman/index.htmlOn commit creation:
- insert a "good" message
- rubocop & rspec will run to make sure everything is good
Git hooks are defined on the hooks folder.
We will use rswag for this.
How it works?
In the spec/integrations folder you can see one example. In this case is about the healthcheck endpoint.
Rswag makes use of integration tests that we write about our endpoints to generate the documentations.
This was the why I liked and started to use it.
So, follow the /spec/integration/healthcheck_spec.rb and start to write new ones about new endpoints that you create.
Don't foget to check the Rswag documentation on github to know more about it.
When ready, just do:
$ ./bin/swaggerizeThis will update the swagger json so, just open the path .../api-docs and check the documentation.
Every time you do rails db:migrate a DB diagram will be built.
You can see the diagram on the pdf that was placed on the root folder of the project.
TBD
TBD
TBD
Lets use Capistranofor deploys. It simple gets one branch code from the project repository and send it to the selected environment (machine).
cap <env_name> deployThe env_name can be staging or production.
For the selection of the branch it will ask you to type in the name of it.
Help spread the code quality word! ❤️