diff --git a/app.rb b/app.rb index 4abb71ec..9be9d24e 100644 --- a/app.rb +++ b/app.rb @@ -1,8 +1,23 @@ require 'sinatra/base' +require 'sinatra/reloader' +require './lib/player' + + class RockPaperScissors < Sinatra::Base - get '/test' do - 'test page' + + get '/' do + erb :index end + post '/names' do + $player_1 = Player.new(params[:player_1_name]) + redirect '/play' + end + + get '/play' do + @name1 = $player_1.name + erb :play + end + run! if app_file == $0 end diff --git a/lib/player.rb b/lib/player.rb new file mode 100644 index 00000000..ad2b2673 --- /dev/null +++ b/lib/player.rb @@ -0,0 +1,8 @@ +class Player + attr_reader :name + + def initialize(name) + @name = name + end + +end \ No newline at end of file diff --git a/spec/features/enter_name.rb b/spec/features/enter_name.rb new file mode 100644 index 00000000..fb8d3868 --- /dev/null +++ b/spec/features/enter_name.rb @@ -0,0 +1,9 @@ +feature 'Enter name' do + scenario 'submitting names' do + sign_in_and_play + + save_and_open_page # will save the web page and open the browser to display it + + expect(page).to have_content 'Hello Kev!' + end +end \ No newline at end of file diff --git a/spec/features/weapon_choice.rb b/spec/features/weapon_choice.rb new file mode 100644 index 00000000..8b298e80 --- /dev/null +++ b/spec/features/weapon_choice.rb @@ -0,0 +1,11 @@ +feature 'see weapons' do + + scenario 'Player can see choice of weapons' do + sign_in_and_play + + expect(page).to have_button("Rock") + expect(page).to have_button("Paper") + expect(page).to have_button("Scissors") + end + +end \ No newline at end of file diff --git a/spec/features/web_helpers.rb b/spec/features/web_helpers.rb new file mode 100644 index 00000000..fcd2d203 --- /dev/null +++ b/spec/features/web_helpers.rb @@ -0,0 +1,5 @@ +def sign_in_and_play + visit('/') + fill_in :player_1_name, with: 'Kev' + click_button 'Submit' +end diff --git a/views/index.erb b/views/index.erb new file mode 100644 index 00000000..94900caf --- /dev/null +++ b/views/index.erb @@ -0,0 +1,11 @@ +