Skip to content
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
14 changes: 12 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
require 'sinatra/base'

class RockPaperScissors < Sinatra::Base
get '/test' do
'test page'

get '/start' do
erb :name_form
end

post '/yourname' do
p params
@name = params[:name]
erb :index
end

run! if app_file == $0

end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code is concise and readable!

10 changes: 6 additions & 4 deletions spec/features/test_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
feature 'test page' do
scenario 'visit test page' do
visit '/test'
expect(page).to have_content('test page')
feature 'name form' do
scenario 'submitting name' do
visit '/start'
fill_in :name, with: 'Amy'
click_button 'Submit your name'
expect(page).to have_content('Amy')
end
end
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'capybara'
require 'capybara/rspec'
require 'rspec'
require 'simplecov'
require 'simplecov-console'

Expand All @@ -19,7 +21,5 @@
RSpec.configure do |config|
config.after(:suite) do
puts
puts "\e[33mHave you considered running rubocop? It will help you improve your code!\e[0m"
puts "\e[33mTry it now! Just run: rubocop\e[0m"
end
end
2 changes: 2 additions & 0 deletions views/game.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<form action="/rockpaperscissors" method="post">
<input type="button" on
7 changes: 7 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% if @name %>
<div id = "name" align = "middle">
<h1><span style = "color:red"><%= @name %></span></h1>
</div>
<% end %>


5 changes: 5 additions & 0 deletions views/name_form.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<form action="/yourname" method="post">
<input type="text" name="name">
<input type="submit" value="Submit your name">
</form>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are 3 .ERB files. Wondering if it is recommended to have just 1 .ERB file as has been the practice in the previous excercises