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

Miranda and Fatuma code reviewing Sabih's code #260

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
source 'https://rubygems.org'

ruby '3.0.2'
ruby '3.0.0'

gem 'sinatra'
gem 'webrick'
gem 'launchy'

group :test do
gem 'capybara'
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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)
mustermann (1.1.1)
Expand Down Expand Up @@ -82,6 +84,7 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
tilt (2.0.10)
unicode-display_width (1.6.1)
webrick (1.7.0)
xpath (3.2.0)
nokogiri (~> 1.8)

Expand All @@ -91,14 +94,16 @@ PLATFORMS

DEPENDENCIES
capybara
launchy
rspec
rubocop (= 1.20)
simplecov
simplecov-console
sinatra
webrick

RUBY VERSION
ruby 3.0.2p107
ruby 3.0.0p0

BUNDLED WITH
2.2.26
2.3.17
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ require 'simplecov-console'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::Console,
# Want a nice code coverage website? Uncomment this next line!
# SimpleCov::Formatter::HTMLFormatter
SimpleCov::Formatter::HTMLFormatter
])
SimpleCov.start
```
Expand Down
28 changes: 25 additions & 3 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
require 'sinatra/base'
class RockPaperScissors < Sinatra::Base

enable :sessions
get '/test' do
'test page'
'test page '
end

run! if app_file == $0
get '/' do
erb :index
end
post '/action_page' do
session[:name] = params[:name]
redirect '/play'
end
get '/play' do
@player_name = session[:name]
erb :play
end
post '/record-action' do
session[:action] = params[:action]
redirect '/result'
end
get '/result' do
@selection = session[:action]
@opponent = [:Rock, :Paper, :Scissors].sample
erb :result
end

Copy link
Author

Choose a reason for hiding this comment

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

Easy to follow and understand.

run! if app_file == $0
end
18 changes: 18 additions & 0 deletions player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Player

Choose a reason for hiding this comment

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

Tests got deleted for this class

def initialize(name)
@name = name
@action = nil
end

def name
return @name
end

def choose_action(action)
@action = action
end

def action
return @action
end
end
18 changes: 18 additions & 0 deletions spec/features/name_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

feature 'Home Page' do

Choose a reason for hiding this comment

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

These are great tests, but there could be more coverage of the results page

scenario 'submit button' do
visit '/'
expect(page).to have_button('Submit')
end
scenario 'to fill the form' do
visit '/'
expect(page.fill_in 'Enter your name:', with: 'Sabih')
end
scenario 'to submit content' do
visit '/'
page.fill_in 'Enter your name:', with: 'Sabih'
page.click_on 'Submit'
expect(page).to have_content 'Sabih'
end
end

2 changes: 2 additions & 0 deletions spec/features/test_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

require 'simplecov'
feature 'test page' do
scenario 'visit test page' do
visit '/test'
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
require 'simplecov'
require 'simplecov-console'


SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::Console,
# Want a nice code coverage website? Uncomment this next line!
# SimpleCov::Formatter::HTMLFormatter
SimpleCov::Formatter::HTMLFormatter
])
SimpleCov.start

Expand Down
7 changes: 7 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

<h1>Welcome to ROCK PAPER SCISSORS</h1>
<form action="/action_page", method='post'>
<label for="name">Enter your name:</label><br>
<input type="text" id="name" name="name" value=""><br>
<input type="submit" value="Submit">
</form>
18 changes: 18 additions & 0 deletions views/play.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h1>Greetings, <%= @player_name %>!</h1>

<div>Choose Rock, Paper or Scissors</div><br>

<form action="/record-action" method="post">
<input type="hidden" name="action" value="Rock"/>
<input type="submit" value="Rock"/>
</form>

<form action="/record-action" method="post">
<input type="hidden" name="action" value="Paper"/>
<input type="submit" value="Paper"/>
</form>

<form action="/record-action" method="post">
<input type="hidden" name="action" value="Scissors"/>
<input type="submit" value="Scissors"/>
</form>
3 changes: 3 additions & 0 deletions views/result.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= "You have selected #{@selection} as your weapon"%><br>
<%= "Your opponent have selected #{@opponent} as weapon"%><br>
<p>Good Choice </p>