18-01-2022
Today's Focus
-
From 'User-Stories' >> Determine test cases - a test case is a good question, and requires an explicit answer. Make the programme pass. (TLDR, design good tests)
-
Ensure explicit answers to tests instead of ( expect(LOGIC).to eq true ) write as (expect(LOGIC).to eq(specific response / data structure )
-
Test methods won't be vague - code-smell? Simple, clear tests, with simple, clear logic?
-
Arrange
-
Act
-
Assert
Debugging
LO
What is a bug?
- code not functioning as intended
- unexpected or unintentional behaviour
- sometimes an error
- zero day vulnerabilities
def add(x, y)
x + y
end
add(5 + 5)
output: 2
If there is an error - look at the error print statement solutions try and systematize your code following the flow use a debugger
Advice
Tighten the loop
-
locate exactly where the problem is
-
puts or p the statement
Error Messages
- Step one, is to hypothesize what the error might be - read and understand the error message
RSpec
class Something
describe ... do
it ... do
expect(subject.method(arg)).to eq expected_output
end
end
end
in the line beginning expect, it kind of tests one object against the equals
.chr method - turns an integer into a character
the exercise 2 is driving me insane, but i think its something to do with the compat method, to remove the nil values from the array
expect(subject).to respond_to(class_method)
will check a method is part of a class
remember Ruby initialize can take default parameters
Pair Programming was fantastic
- smashed through the basics, and got onto the more complex problems!
- what made working with O so good?