Rock, Paper, Scissors. Makers Academy Challenge
Our week 3 weekend challenge was to design a rock paper scissors web application, using RSpec, Capybara, Sinatra and Ruby. The weeks challenge seemed to go well, working alongside pair programmers with useful walkthroughs to refer to if stuck. Being faced with writing a whole programme from scratch, without assistance or support seemed rather daunting.
I started off well, using steps from the last weeks challenge as guidance to add a ‘registration’ feature and post names from a form through to the server to display the params as a welcome message in a view file. I set up my files nicely and knew which ruby code I wanted to use to run a basic functional site. I hit a wall however, half way through Saturday and could not progress further without some kind of assistance. I knew what I wanted to do in terms of the code base, however I got significantly confused with trying to link the various feature and unit tests, to the main controller app.rb and through to the main ruby files and view files. After a few hours attempting to progress, I knew it was going nowhere and decided instead to use one of our instructor’s (Sam Morgan) code base as a foundation to which to understand the processes and design to make this work.
I didn’t simply copy and paste the code into my own file, but instead went through each step, writing the feature and unit tests and then trying to write the code to make them pass myself. I learnt new skills through doing it this way, like how to pass sessions as arguments to initialize classes with multiple ‘options’ such as whether a user may choose to select a rock, paper or scissors. I also learnt how to use ruby’s srand method to create a ‘spoof’ random number in order to generate a random selection in order to set up tests in capybara. I consolidated knowledge learnt in the week on exactly session data was passed from a form, through to the server using a POST command, and redirected to a different route in order for the program to run.
Whilst the code itself is relatively straightforward, I am still struggling with testing and writing adequate feature and unit tests. I need to find some time to continue to study this, especially with respect to mocking. I am happy that I fully understand Sam’s code base and was content that I worked my way through it, changing it slightly to make it more understandable. I also added additional functionality by adding the ‘lizard and spock’ options to the game. I also played around with styling, inserting images to replace submit buttons, and incorporated flexbox to layout the icons and text in a more centralized way.