Last active
June 8, 2020 04:02
-
-
Save IvanDerlich/472407ef0bb786619bb71ba64b2de27e to your computer and use it in GitHub Desktop.
Gist created for Rspec Article. Published first in medium.
This file contains hidden or 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
require('./calculator.rb') | |
context "Calculator" do | |
let(:calc){Calculator.new()} | |
describe "Addition" do | |
it "5 + 4 = 9" do | |
expect( | |
calc.addition(4,5) | |
).to be(9) | |
end | |
it "5 + 4 != 10" do | |
expect( | |
calc.addition(4,5) | |
).not_to be(10) | |
end | |
end | |
describe "Substraction" do | |
it "7 - 4" do | |
expect( | |
calc.substraction(7,4) | |
).to be(3) | |
end | |
it "8 - 4" do | |
expect( | |
calc.substraction(8,4) | |
).not_to be(5) | |
end | |
end | |
describe "Multiplication" do | |
it "3 * 5" do | |
expect( | |
calc.multiplication(3,5) | |
).to be(15) | |
end | |
it "3 * 5" do | |
expect( | |
calc.multiplication(3,5) | |
).not_to be(24) | |
end | |
end | |
describe "Division" do | |
it "6 / 3" do | |
expect( | |
calc.division(6,3) | |
).to be(2.0) | |
end | |
it "6 / 3" do | |
expect( | |
calc.division(6,3) | |
).not_to be(55) | |
end | |
it "7 / 2" do | |
expect( | |
calc.division(7,2) | |
).to be(3.5) | |
end | |
it "1 / 0", :focus do | |
expect( | |
calc.division(1,0) | |
).to eq('Positive Infinity') | |
end | |
it "0 / 0" do | |
expect( | |
calc.division(0,0) | |
).to eq('Indeterminate') | |
end | |
it "-1 / 0" do | |
expect( | |
calc.division(-1,0) | |
).to eq('Negative Infinity') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment