31-01-2022
Meta Stuff
config, updates, installs, software, etc
Today's Foci
Focus 1
- New template for the bud forms - they're free-formish, but take too long. They need only be around 30 mins to complete
- Make a new form template - test in Focus 2
Focus 2
- Use the above template to complete forms 3 & 4
- They will look good ( remember 4th Feb FRIDAY ) is deadline. Have done by Thurs latest.
Focus 3
- Quickly read through the OOD I may have missed
- Make notes on anything important or unknown
Focus 4
- Make a start on the web stuff - see what kind of stuff it involves
- Make notes below of what I must do - believe its on the apprenticeship page
Topic
Code review
8 user stories working - met target! ace! :)
stuck on refactoring meeting room instances in office_spec.rb
Loving the README - concisely explained their thought process - I can understand their point of view within a few sentences
Commited after each passing test!
Office class clear, good SRP
office.list_available_rooms.to eq meeting_room4 - should this be [meeting_room4]?
fantastic work all around!
What went well for me? covered lots of stuff, apparently my walkthrough file was useful.
Maybe keep the walkthrough? but make it more concise, if I can - difficult because of stream of consciousness when writing.
What could I improve?
My README could be clearer. Perhaps follow this persons style?
What went well for the other person?
Their code was concise and legible - I don't have the knowledge to help them more. I could have helped with the question they had to a greater extent? Step through their code with them? I don't know.
How could I improve the review I give?
I need to understand the code faster - README - then start from a top down view of their code. Then I can target specifics, I think? After, step through the code commit by commit, to understand their contruction process. I couldn't figure out how because of the repository visibility set by the fork's owner.
The Web
Ruby feature testing - Capybara
use a Sinatra - Web Framework
Remember these are third party code!
Debug web applications
Explain and diagram the HTTP req/response cycle
Explain the MVC pattern
Tracking these goals
Summarise Capybara README
Summarise Sinatra README
Debugging a web app
Diagram the HTTP req/res cycle
Diagram MVC
Sinatra
A DSL - a Domain Specific Language ( as opposed to a General Purpose Language ) - so is a DSL like MarkDown?
require 'sinatra'
get '/' do
'Hello world!'
end
runs with ruby '[APPNAME].rb'
Sinatra default port at localhost:4567
maybe grab sinatra reloader?
gem install thin?
routes include
get - post - put - patch - delete - options - link - unlink
/foo
is not
/foo/
Routes take parameters such as
get '/hello/:name' do
# matches "GET /hello/foo" and "GET /hello/bar"
# params['name'] is 'foo' or 'bar'
"Hello #{params['name']}!"
end
Immediately had a few issues trying to run Capybara - one was simply a typo, but I also didn't have the gecko webdriver installed
updated Ruby to latest, made the Gemfile, ran bundle to install them in the environment.
install pry again
thankfully a quick fix for others appears to be Ruby 3.1.0 for some Capybara::DSL error
Pry / Capybara
click_link 'https://some.link'
click_button 'Button text'
check('checkbox.name' || 'checkbox.[i]')
use capybara to select a section
within('section .fourth') do
click_button "We're the same..but in different sections"
end
buttons can also be targeted with their ID tags
click_button('left')
buttons can be targeted via their classes too!
find('button.left').click
you can even fill in forms!
fill_in 'name', with: 'Bob'
Pairing Into to the Web
two components - resources stored on servers, and entities that request said resources ( usually, clients )
I go to Google, google sends me back a handshake with a file
client server model
distributed application structure
a server hosts applications, which wait for requests to come in
a client usually requests information from the server
encoding for gzip and deflate?
parameters in http come as key:value pairs - you could pass this on in the query string, appended to the url
get
post
put
delete
head
trace
options
Status Codes
1XX: Informational Messages
2XX: Successful
3XX: Redirect
4XX: Client error
5xx: Server Error
lookup: general headers, and entity headers
ROR: ActionController, ActionDispatch
HTTP Response
GET / HTTP/1.1
method: GET, path: '/', http_version: '1.1'
Use GET for safe actions
And POST for unsafe actions
GET
GET requests can be cached
GET requests can remain in the browser history
GET requests can be bookmarked
GET requests can be distributed & shared
GET requests can be hacked
POST
Sensitive data
Use Post dealing with long request
use get in AJAX
got to Returning HTML