Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stevie Spiegl RPS #2115

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4359d10
first commit
S-Spiegl May 7, 2022
1a24ee3
added app.rb and testing_infrastructure_spec
S-Spiegl May 7, 2022
cea74c9
commit check
S-Spiegl May 7, 2022
43edfb8
added play.erb
S-Spiegl May 7, 2022
e071a99
added Player model, '/play' route, and redirected '/name'
S-Spiegl May 7, 2022
392b36c
added play_game_spec and tests
S-Spiegl May 7, 2022
b136975
the model and controller are on speaking terms
S-Spiegl May 7, 2022
3be0405
game works. needs more tests
S-Spiegl May 7, 2022
0736433
some refactoring, several tests still need writing
S-Spiegl May 7, 2022
8bfb302
replaced buttons with images and updated tests accordingly
S-Spiegl May 7, 2022
23d4805
added capybara tests for various outcomes
S-Spiegl May 8, 2022
c1a4456
added background image for results screen
S-Spiegl May 8, 2022
0a48d3e
getting new errors
S-Spiegl May 8, 2022
af14b6c
come back here for comments/questions
S-Spiegl May 8, 2022
7fc16b4
refactored controller, took out comments
S-Spiegl May 8, 2022
f0c7b17
committing before changing computers
Jun 5, 2022
6ced6bc
Update README.md
S-Spiegl Jul 20, 2022
598460d
Update README.md
S-Spiegl Jul 20, 2022
d7f237f
Update README.md
S-Spiegl Jul 20, 2022
b331630
moved styling to stylesheet
S-Spiegl Aug 4, 2022
0162508
Merge branch 'main' of https://github.com/S-Spiegl/rps-challenge
S-Spiegl Aug 4, 2022
737ec52
set images as row, moved more logic to css
S-Spiegl Aug 4, 2022
e8cacd9
tidied up css for all views
S-Spiegl Aug 4, 2022
82d354a
finished tidying up css
S-Spiegl Aug 4, 2022
06a966c
Update README.md
S-Spiegl Aug 4, 2022
633c77b
added movies
S-Spiegl Aug 4, 2022
ddb2463
Merge branch 'main' of https://github.com/S-Spiegl/rps-challenge
S-Spiegl Aug 4, 2022
5dcf235
set up databases
S-Spiegl Aug 4, 2022
c5a6c4f
database accepting booleans for each go to represent wins, draws and …
S-Spiegl Aug 4, 2022
bb949f7
incrementing won, drew, lost columns in postgres
S-Spiegl Aug 4, 2022
9d44f07
renamed game to round;
S-Spiegl Aug 4, 2022
88bf62a
keeps track of score and prints to screen
S-Spiegl Aug 5, 2022
1353f7a
about to branch off for deployment
S-Spiegl Aug 5, 2022
dae923e
still undeployed
S-Spiegl Aug 5, 2022
6f8e164
Update README.md
S-Spiegl Aug 6, 2022
177486c
switched to improving tests branch
S-Spiegl Aug 6, 2022
1c2215f
mocking for round_spec passing
S-Spiegl Aug 6, 2022
06e98e2
tidied up round_spec
S-Spiegl Aug 6, 2022
f3b1de1
tests working
S-Spiegl Aug 6, 2022
1cb42bb
Merge pull request #1 from S-Spiegl/improving-tests
S-Spiegl Aug 6, 2022
d143894
merged
S-Spiegl Aug 6, 2022
da77118
set up test database
S-Spiegl Aug 6, 2022
db0dba3
added procfile
S-Spiegl Aug 7, 2022
2eab430
updated gemfile
S-Spiegl Aug 7, 2022
63b1b62
updated gemfile again
S-Spiegl Aug 7, 2022
2d23f71
testing if PG is the issue
S-Spiegl Aug 7, 2022
508234a
testing if PG is the issue
S-Spiegl Aug 7, 2022
a74ace6
fixing PG
S-Spiegl Aug 7, 2022
66baab1
fixing PG still
S-Spiegl Aug 7, 2022
64d1602
fixing PG still
S-Spiegl Aug 7, 2022
a34292f
fixing PG still
S-Spiegl Aug 7, 2022
10ba08e
fixing PG still
S-Spiegl Aug 7, 2022
b7773b9
fixing PG still
S-Spiegl Aug 7, 2022
1a95f63
fixing PG still
S-Spiegl Aug 7, 2022
72c4d4f
fixing PG still
S-Spiegl Aug 7, 2022
63bb33e
fixing PG still
S-Spiegl Aug 7, 2022
cebb680
still trying to establish connection
S-Spiegl Aug 7, 2022
852c43f
still trying to establish connection
S-Spiegl Aug 8, 2022
c252626
got PG working by transferring some of the logic into the round.rb, b…
S-Spiegl Aug 8, 2022
0401afd
successfully deployed. Now need to edit table functionality
S-Spiegl Aug 8, 2022
e0db0da
Update README.md
S-Spiegl Aug 8, 2022
2d98a80
Update README.md
S-Spiegl Aug 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
Tech Test Submission Requirements/Guidelines
======
# Tech Test Submission Requirements/Guidelines

Before submitting your test, please review the requirements/guidelines belows. Note that the requirements are mandatory and if you do not satisfy them we won't review your code (we don't mean to be harsh but this is based on the minimum expectations that our hiring partners require when you submit code for tech tests).

Requirements
------
## Requirements

* We use [Hound CI](https://houndci.com/) to check for violations to our style guide. When you submit your Pull Request, please then check over and correct everything that Hound has sniffed out that is wrong with your code (unless you feel you really can't do anything to fix it). Once you've fixed Hound errors, push your code again and the Pull Request should update automatically.
* Make sure you have written your own README that briefly explains your approach to solving the challenge.
* If your code isn't finished it's not ideal but acceptable as long as you explain in your README where you got to and how you would plan to finish the challenge.
* All code must be written test-first - we're looking for 100% test coverage or as near as possible to that figure.
* Ensure all your tests are passing.
- We use [Hound CI](https://houndci.com/) to check for violations to our style guide. When you submit your Pull Request, please then check over and correct everything that Hound has sniffed out that is wrong with your code (unless you feel you really can't do anything to fix it). Once you've fixed Hound errors, push your code again and the Pull Request should update automatically.
- Make sure you have written your own README that briefly explains your approach to solving the challenge.
- If your code isn't finished it's not ideal but acceptable as long as you explain in your README where you got to and how you would plan to finish the challenge.
- All code must be written test-first - we're looking for 100% test coverage or as near as possible to that figure.
- Ensure all your tests are passing.

Desirable
-------
## Desirable

* Set up [Travis CI](https://travis-ci.org/) on your own repo and add a [status badge](http://docs.travis-ci.com/user/status-images/) to your README showing that all tests are passing - and make sure it passes our own CI when you submit your PR.
- Set up [Travis CI](https://travis-ci.org/) on your own repo and add a [status badge](http://docs.travis-ci.com/user/status-images/) to your README showing that all tests are passing - and make sure it passes our own CI when you submit your PR.

Guidelines
-------
## Guidelines

* Ensure you've understood the specification and built the code according to the challenge guidelines.
* Read through [Code Reviews :pill:](https://github.com/makersacademy/course/blob/main/pills/code_reviews.md) to understand what we're looking for in your code.
- Ensure you've understood the specification and built the code according to the challenge guidelines.
- Read through [Code Reviews :pill:](https://github.com/makersacademy/course/blob/main/pills/code_reviews.md) to understand what we're looking for in your code.
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ source 'https://rubygems.org'
ruby '3.0.2'

gem 'sinatra'
gem 'sinatra-contrib'
gem 'webrick'
gem 'puma'
gem 'rack'

group :test do
gem 'capybara'
gem 'rspec'
gem 'pg'
gem 'simplecov', require: false
gem 'simplecov-console', require: false
end

group :development, :test do
gem 'rubocop', '1.20'
gem 'sinatra'
gem 'sinatra-contrib'
gem 'rack'
gem 'webrick'
gem 'launchy'
end

group :production do
gem 'pg'
end
22 changes: 21 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ GEM
xpath (~> 3.2)
diff-lcs (1.4.4)
docile (1.4.0)
launchy (2.5.0)
addressable (~> 2.7)
mini_mime (1.1.1)
mini_portile2 (2.6.1)
multi_json (1.15.0)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
nokogiri (1.12.3)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.4.1)
public_suffix (4.0.6)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.5.2)
rack (2.2.3)
rack-protection (2.1.0)
Expand Down Expand Up @@ -76,10 +83,17 @@ GEM
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
sinatra-contrib (2.1.0)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.1.0)
sinatra (= 2.1.0)
tilt (~> 2.0)
terminal-table (3.0.1)
unicode-display_width (>= 1.1.1, < 3)
tilt (2.0.10)
unicode-display_width (2.0.0)
webrick (1.7.0)
xpath (3.2.0)
nokogiri (~> 1.8)

Expand All @@ -88,14 +102,20 @@ PLATFORMS

DEPENDENCIES
capybara
launchy
pg
puma
rack
rspec
rubocop (= 1.20)
simplecov
simplecov-console
sinatra
sinatra-contrib
webrick

RUBY VERSION
ruby 3.0.2p107

BUNDLED WITH
2.2.26
2.3.15
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec rackup config.ru -p $PORT
59 changes: 42 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
# RPS Challenge

Instructions
-------
# <a href="https://rock-paper-spiegl.herokuapp.com/">Play the deployed app here!!!</a>
<!-- ## App currently down while I implement database - 8/8/22 -->

* Feel free to use google, your notes, books, etc. but work on your own
* If you refer to the solution of another coach or student, please put a link to that in your README
* If you have a partial solution, **still check in a partial solution**
* You must submit a pull request to this repo with your code by 9am Monday morning
### If you'd still rather play it locally, do the following:

Task
----
- clone this repo
- run ```bundler``` to install dependencies
- run ```rackup```
- navigate to the port specified by rackup
- choose wisely...
- (the game keeps track of your score - updated videos to follow)


## Enter your name



https://user-images.githubusercontent.com/98267087/182941868-333978af-56bf-47ae-a9c7-510ac6216a22.mov

## Choose an option...

https://user-images.githubusercontent.com/98267087/182941875-07bc66aa-8a57-423f-90fa-2e8c4dab266f.mov

## Choose another option...

https://user-images.githubusercontent.com/98267087/182941881-57eba3fc-45fd-4988-84dc-6498bbdd9ec8.mov

## Choose another option...

https://user-images.githubusercontent.com/98267087/182941887-f2594826-201f-49d5-aff8-25ef4432662f.mov


## Further steps
- a login, with a database to keep scores
- different images/messages depending on what the outcome is

## Task

Knowing how to build web applications is getting us almost there as web developers!

Expand All @@ -35,11 +62,10 @@ Hints on functionality
- the game will choose a random option
- a winner will be declared


As usual please start by

* Forking this repo
* TEST driving development of your app
- Forking this repo
- TEST driving development of your app

[You may find this guide to setting up a new Ruby web project helpful.](https://github.com/makersacademy/course/blob/main/pills/ruby_web_project_setup_list.md)

Expand All @@ -59,14 +85,13 @@ Use the _special_ rules ( _you can find them here http://en.wikipedia.org/wiki/R

In code review we'll be hoping to see:

* All tests passing
* High [Test coverage](https://github.com/makersacademy/course/blob/main/pills/test_coverage.md) (>95% is good)
* The code is elegant: every class has a clear responsibility, methods are short etc.
- All tests passing
- High [Test coverage](https://github.com/makersacademy/course/blob/main/pills/test_coverage.md) (>95% is good)
- The code is elegant: every class has a clear responsibility, methods are short etc.

Reviewers will potentially be using this [code review rubric](docs/review.md). Referring to this rubric in advance may make the challenge somewhat easier. You should be the judge of how much challenge you want this at this moment.
Reviewers will potentially be using this [code review rubric](docs/review.md). Referring to this rubric in advance may make the challenge somewhat easier. You should be the judge of how much challenge you want this at this moment.

Notes on test coverage
----------------------
## Notes on test coverage

Please ensure you have the following **AT THE TOP** of your spec_helper.rb in order to have test coverage stats generated
on your pull request:
Expand Down
Binary file added RPS1.mov
Binary file not shown.
Binary file added RPS2.mov
Binary file not shown.
Binary file added RPS3.mov
Binary file not shown.
Binary file added RPS4.mov
Binary file not shown.
48 changes: 48 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'sinatra/base'
require 'sinatra/reloader'
require './lib/player'
require './lib/round'
require './lib/game'
# require './database_connection_setup'

class RockPaperScissors < Sinatra::Base
configure :development do
register Sinatra::Reloader
end

enable :sessions

get '/' do
$game = Game.new
erb :form
end

post '/play' do
session[:player] = params[:player]
$player = Player.new(params[:player])
@player_name = $player.name
@game = $game
erb :play
end

post '/play_again' do
# session[:player] = params[:player]
# $player = Player.new(params[:player])
# @player_name = $player.name
@game = $game
erb :play_again

end

post '/battle' do
@player = $player
@player_weapon = @player.select_weapon(params[:player_choice])
round = Round.new(@player_weapon, $game)
@message = round.engine
@computer_weapon = round.computer_weapon
erb :battle
end

# Start the server if this file is executed directly (don't change the line below)
run! if app_file == $0
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great file, concise, good use of class names and instance and global variables

2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative 'app'
run RockPaperScissors
7 changes: 7 additions & 0 deletions database_connection_setup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require './lib/database_connection'

if ENV['RACK_ENV'] == 'test'
DatabaseConnection.setup('rps_test')
else
DatabaseConnection.setup('rps')
end
3 changes: 3 additions & 0 deletions db/migrations/01_create_databases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE DATABASE rps;

CREATE DATABASE rps_test;
7 changes: 7 additions & 0 deletions db/migrations/02_create_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE scores (id SERIAL PRIMARY KEY, won INT, drew INT, lost INT);
INSERT INTO scores (won, drew, lost) VALUES(0, 0, 0);


-- CREATE TABLE users (id SERIAL PRIMARY KEY, username VARCHAR(30));

-- CREATE TABLE spaces (id SERIAL PRIMARY KEY, name_of_space VARCHAR(100), available BOOLEAN, user_id INT, description VARCHAR(240), price_per_night INT);
Loading