-
Notifications
You must be signed in to change notification settings - Fork 257
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
First Commit #258
base: main
Are you sure you want to change the base?
First Commit #258
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
require 'sinatra/base' | ||
require 'sinatra/reloader' | ||
|
||
class RockPaperScissors < Sinatra::Base | ||
get '/test' do | ||
'test page' | ||
set :sessions, true | ||
configure :development do | ||
register Sinatra::Reloader | ||
end | ||
get '/' do | ||
"hey" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may need to introduce erb (:index) here so that the user can move forward onto next page |
||
|
||
post '/names' do | ||
$player1 = Player.new(params[:Player1]) | ||
$player2 = Player.new(params[:Player2]) | ||
redirect '/play' | ||
end | ||
|
||
get '/play' do | ||
@player1 = $player1.name | ||
@player2 = $player1.name | ||
erb :play | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does :play need to be in brackets? |
||
end | ||
|
||
run! if app_file == $0 | ||
|
||
run! if app_file == $0 | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
require_relative './app' | ||
require_relative './app.rb' | ||
run RockPaperScissors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Player | ||
def initialize(name) | ||
@name = name | ||
end | ||
|
||
def name | ||
return name | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. single responsibility principle seems good here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'player' | ||
RSpec.desribe Player do | ||
context "initially" do | ||
it "returns a name" do | ||
player = Player.new("Ronan") | ||
expect( player.name ).to eq "Ronan" | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test is easy to understand |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
feature 'test page' do | ||
scenario 'visit test page' do | ||
visit '/test' | ||
expect(page).to have_content('test page') | ||
end | ||
end | ||
# feature 'test page' do | ||
# scenario 'visit test page' do | ||
# visit '/test' | ||
# expect(page).to have_content('test page') | ||
# end | ||
# end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
<form action='/' method="post"> | ||
<ul> | ||
<li> | ||
<label for="Player1">Player 1</label> | ||
<input type="text" id="Player1" name="Player1"> | ||
</li> | ||
<li> | ||
<label for="Player2">Player 2</label> | ||
<input type="text" id="Player2" name="Player2"> | ||
</li>a | ||
<li> | ||
<input type="submit" value="Submit"> | ||
</li> | ||
</ul> | ||
</form> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nicely formatted html (with the indentations and stuff) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1> | ||
<%= "#{@player1} vs #{@player2}" %> | ||
</h1> | ||
|
||
<h1> | ||
<%= "#{@player1}, youre fighting #{@player2} who has 10hp remaining!" %> | ||
</h1> | ||
|
||
<form action='/attack' method="get"> | ||
<input type="submit" value="Attack"> | ||
</form> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a require './lib/player'