Jim's
Tutorials

Fall 2018
course
site

Testing Week 1

Familiarize myself [09/10/2018]

So I decided to just start with reading on this one, testing is something I'd like to do my plan on but at the same time, only have a vague familiarity about it and must explore further before diving in. So I read some articles.

Ruby Unit::Testing documentation

Read Jims article on testing and the ycombinator discussion about it

Also I tried making an exercise in ruby and breaking into it with pry, but couldn't really figure out how. Will return to it.

53: require 'pry'
    54: puts "what activity would you like to do?"
 => 55: binding.pry
    56: if (rand(4)) == 1
    57:     puts "ok jetskiing"
    58: elsif (rand(4)) == 2
    59:     puts "ok animals!"
    60: elsif (rand(4)) == 3

[1] pry(main)> if
[1] pry(main)* elsif
SyntaxError: unexpected keyword_elsif
[1] pry(main)> rand (4))
SyntaxError: unexpected ')', expecting end-of-input
[1] pry(main)>

Try finding things as you debug using pry

So a lot of debugging is uncovering errors, which means I want to be able to seek & destroy issues within the code, so I experimented a bit with finding specific issues in the code based on the nil lesson and documentation I read:

location = "bind".index("n")
if location.nil?
    puts "not there"
else
    puts "location is: #{location}"
end

And this worked, totally basic but I'm getting the idea how to make a baby test. This also clarifies how my code is "expressing" itself.

street-show git:(master) ✗ ruby code.rb
location is: 2

Making sure that if a value is simply not put in, doesn't trick the code to accept it(the idea of verifying that information exists before you check it)

bin = 20
if bin && bin >= 20
    puts "yes"
else
    puts "no"
end