Written by James Torkornoo github:@mrtorks
Things you may want to cover:
-
Ruby version 3.0.0
-
Rails 6.1.4
System dependencies
- MacOS/Linux preferrably. Any system configured with ruby and rails should work
- Redis installed and running
Configuration
-
Ensure Ruby and rails are installed
-
Run
bundle install
-
Have Homebrew install redis
-
Run command below for MacOS/Linus or start redis on your preferred system
brew services start redis
Database creation
- Not needed as active record is not used
- How to run the test suite
- For Requests
-
Ping
rspec spec/requests/ping_spec.rb
-
Posts
rspec spec/requests/posts_spec.rb
-
- For Requests
- For Routes
-
Ping
rspec spec/routing/ping_routing_spec.rb
-
Posts
rspec spec/routing/posts_routing_spec.rb
-
-
For Class Method Errors
- Posts
rspec spec/models/post_spec.rb
- Test if Rails cache is working
2.times.map { Rails.cache.fetch("test", expires_in: 1) { rand } }.uniq.length == 1
- Nice to use Postman/Insomnia to test API
-
GET (posts) url example =
http://<your-url>/api/posts?tags=tech&direction=desc
http://<your-url>/api/posts?tags=tech,health,culture,politics&direction=desc
http://<your-url>/api/posts?tags=tech,health,culture,politics&sortBy=reads&direction=desc
-