-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User story 1: added config.ru file and ENV[RACK_ENV] = test
require File.join(File.dirname(__FILE__), .., app.rb) in the spec_helper: rspec now passing correctly. enabled session in controller, stored instance variable in controller [started again with tests this time]
- Loading branch information
1 parent
ac76d85
commit a95f3a3
Showing
15 changed files
with
85 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'sinatra/base' | ||
require 'sinatra/reloader' | ||
|
||
class RockPaperScissors < Sinatra::Base | ||
configure :development do | ||
register Sinatra::Reloader | ||
end | ||
enable :sessions | ||
|
||
get '/' do | ||
erb :index | ||
end | ||
|
||
post '/name' do | ||
session[:name] = params[:name] | ||
redirect '/play' | ||
end | ||
|
||
get '/play' do | ||
@name = session[:name] | ||
erb :play | ||
end | ||
|
||
run! if app_file == $0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require './app' | ||
run RockPaperScissors |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
# As a marketeer | ||
# So that I can see my name in lights | ||
# I would like to register my name before playing an online game | ||
|
||
feature 'registering name' do | ||
scenario 'register and see my name' do | ||
visit '/' | ||
fill_in 'name', with: 'Benjamin' | ||
click_button 'Submit' | ||
expect(page).to have_content 'Benjamin' | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
ENV['RACK_ENV'] = 'test' | ||
|
||
require File.join(File.dirname(__FILE__), '..', 'app.rb') | ||
|
||
require 'capybara' | ||
require 'capybara/rspec' | ||
require 'rspec' | ||
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.start | ||
Capybara.app = RockPaperScissors | ||
|
||
|
||
# SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ | ||
# SimpleCov::Formatter::Console, | ||
# # Want a nice code coverage website? Uncomment this next line! | ||
# # SimpleCov::Formatter::HTMLFormatter | ||
# ]) | ||
# SimpleCov.start | ||
|
||
# For accurate test coverage measurements, require your code AFTER 'SimpleCov.start' | ||
# # For accurate test coverage measurements, require your code AFTER 'SimpleCov.start' | ||
|
||
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 | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<form method="POST" action="/name"> | ||
<input type="text" name="name" value="" /> | ||
<input type="submit" value="Submit" /> | ||
</form> | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1 @@ | ||
Ok! <%= @player %>, choose your weapon: <br> | ||
<br> | ||
<form action="/result"> | ||
<input type="radio" value="Rock"> | ||
<input type="radio" value="Paper"> | ||
<input type="radio" value="Scissors"> | ||
</form> | ||
|
||
<%# Options: | ||
Pick Rock, paper, or scissors %> | ||
|
||
@player.play(result) | ||
Hello, <%= @name %>! |
Oops, something went wrong.