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

amended the route #250

Open
wants to merge 3 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
22 changes: 20 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
require 'sinatra/base'
class RockPaperScissors < Sinatra::Base
get '/test' do
'test page'
get '/' do
# p params
# @random_name = params[:name]
erb(:index)
end

get '/' do
erb(:index)
end

post '/' do
p params
@player_name = params[:name]
p @player_name
@player_move = params[:move]
p @player_move
erb(:index)
end

run! if app_file == $0
end



Binary file added public/download.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions spec/app_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "app"

RSpec.describe "rock, paper, scissors" do
it "has a route to a start page" do
expect(page).to \
Comment on lines +4 to +5
Copy link

Choose a reason for hiding this comment

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

I figured out the feature test structure from this page in the pairing challenges, hopefully that helps it make sense. https://github.com/makersacademy/course/blob/main/apprenticeships_intro_to_the_web/walkthroughs/entering_players.md

39 changes: 39 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<% if @player_name.nil? %>
<p> Please enter your name </p>
<form action="/" method="post">
<input type="text" name="name">
<input type="submit" value="Submit">
</form>

<% elsif @player_name %>

<h1> Greetings and salutations <%= @player_name %> </h1>

<p> Choose your weapon! </p>
Comment on lines +10 to +12
Copy link

Choose a reason for hiding this comment

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

Haha love these touches.

<form action="/" method="post">
<input type="hidden" name="move" value="rock">
<button type="submit">rock</button>
</form>

<form action="/" method="post">
<input type="hidden" name="move" value="paper">
<button type="submit">paper</button>
</form>

<form action="/" method="post">
<input type="hidden" name="move" value="scissors">
<button type="submit">scissors</button>
</form>
Comment on lines +24 to +26
Copy link

Choose a reason for hiding this comment

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

there's some indentation differences here


<% elsif @player_move = "rock" %>
<h1> You chose </h1>

<% end %>



<img src='/download.jpeg' />