Created
June 11, 2019 15:46
-
-
Save Alacrity01/d308d697ed1b2c6160b07788b3871369 to your computer and use it in GitHub Desktop.
Week 8, Day 2 (no class on Monday, no Day 1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Automated Testing (also known as regression testing) | |
Testing usually has a note that explains what the code does. Can improve the code written. Leads into TDD - Test Driven Development. | |
Can incorporate Rspec (stands for Ruby specs - we will use this). Doesn't come standard with rails. | |
<|terminal> | |
mkdir rspec_exercises | |
<calculator.rb> | |
require 'rspec' | |
... | |
calculator = Calculator.new | |
RSpec.describe Calculator do | |
describe '#add' do | |
# code that tests the add method | |
it 'should return the sum of two numbers' do # between it and do is a string | |
calculator = Calculator.new # must repeat this line to create a new instance of Calculator | |
result = calculator.add(1, 4) | |
expect(result).to eq(5) # could also combine these lines to: expect(calculator.add(1,4)).to eq(5) | |
end | |
end | |
describe '#subtract' do | |
# code that tests the subtract method | |
end | |
end | |
<|terminal|> | |
rspec calculator.rb | |
---> . | |
^ known as a 'pip', means it passed. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment