- Step one: Clone the repo
git clone https://github.com/jigmetnamgyal/rps-game.git
- Step two: Install the gem
bundle install
- Step three: Create the database
rails db:create
- Ste four: Run the
rspec
rspec
- Step five: Start the server
rails s
- Step Five: Open Postman or Altair and send the following request
query {
gameStart(userChoice: rock) {
result
}
}
-
This is a small rock paper scissor game implemented in Ruby on Rails using GraphQL API and Faraday gem for 3rd party integration.
-
A user make a choice from Rock, paper and Scissor and compete with the crub bot
-
The application allow a user to choose rock, paper, or scissors
-
The application make a request to the external api to retrieve the server’s throw.
-
Error handling is done
-
If the api does not work or run out of time, an alternative of generating a random throw locally is handled by rescuing
Faraday::ConnectionFailed
-
The application then respond with a result - whether the user won, lost or tied based on the server's throw
- Rock beats scissors
- Scissors beats paper
- Paper beats rock
- Identical throws tie (rock == rock, etc.)
- Hammer beats all the other options.
The rule for the hammer with the understanding that
- hammer crushes rocks
- hammer dulls scissor
- hammer disproves paper
- If we threw in any other as a choice, it will throw error and specify user that the input is invalid choice.
- GraphQL for API
- Faraday to make external api request and error handling
- Pry for debugging
- rspec-rails for unit testing
- rubocop-rails and rubocop-rspec for code clean up
- web-mock for stubbing 3rd part api for testing