This project created an API implementation of the game Battleship. After authorization and activation through an email, a player can play against another player through API interactions. To see all the endpoints utilized, in a game look this endpoint explanation. Through utilizing Twilio's API, the game also sends SMS updates after the opponent has taken his or her turn. A deployed version of the api can be visited here.
- Getting Started
- Prerequisites
- Installing
- Running the Tests
- Tests
- Built With
- Contributing
- Authors
- Acknowledgements
These instructions will get you a copy of the battleshift API up and running on your local machine for development and testing purposes.
- Ruby, version 2.5
- Rails, version 5.1.5
- Puma, version 3.7
- Rspec-Rails
After cloning down this repository, change into the directory battleshift
and run:
bundle
To setup the database necessary for this API, run the following commands:
rails db:create db:migrate db:seed
In order to run the test suite, run the following command:
bundle exec rspec
- This test suite implements mocks, stubs, doubles, and spies. The following common edge cases in playing a game are tested.
- User cannot shoot at a position not on the board
rspec spec/requests/api/v1/games/shots_spec.rb
- User cannot shoot twice in a row
rspec spec/requests/api/v1/games/shots_spec.rb
- User cannot shoot after the game is over
rspec spec/requests/api/v1/games/shots_spec.rb
- User cannot place an extra ship
rspec spec/requests/api/v1/games/ships_spec.rb
- User cannot place a ship on a location not on the board
rspec spec/requests/api/v1/games/ships_spec.rb
- User cannot place a ship that in a spot already occupied by another ship
rspec spec/requests/api/v1/games/ships_spec.rb
- User must place ships in same column or row
rspec spec/requests/api/v1/games/ships_spec.rb
- User cannot post to a game they’re not playing in
rspec spec/requests/api/v1/games/user_cannot_post_to_game_they_are_not_in_spec.rb
- Inactive users cannot post to a game
spec/requests/api/v1/games/inactive_user_cannot_post_spec.rb
- User cannot login in with bad info
spec/features/user_can_login_spec.rb
- User cannot shoot at a position not on the board
Please feel free to submit pull requests and suggestions to this repository. We would love your feedback.
- Thanks to our wonderful instructors at Turing