Sean Luckett testing calculator submission#86
Conversation
Gemfiles allow RubyMine to run tests without extra config.
remis1889
left a comment
There was a problem hiding this comment.
Write separate statements for each of the test cases. Missing test cases for stringify.
| describe 'sqrt' do | ||
| it 'returns the square root of a number' do | ||
| expect(calc.sqrt(9)).to eq 3 | ||
| expect(calc.sqrt(8)).to eq 2.83 |
There was a problem hiding this comment.
the result for square root of a non-round argument should have 2 decimal places exactly
|
I could certainly change the test from eq 3 to eq 3.00 to test this. Line 72 of the spec tests "stringify." I disagree with writing separate statements for each test case. That is something taught to beginning testers, yes, but the important part is tests are understandable. Each expectation line is grouped under its intent. Putting each test case in its own block creates a lot of "noise" in the spec, making the reader have to hunt down and read a lot to understand what's going on. I do appreciate the feedback! 👍 |
|
I agree. Like you said, it is usually encouraged when you start learning about testing. Since this assignment is one of the first in RSpec unit, I made that comment. Once you start testing more complex applications it is better to group test cases so as to reduce the noise. |
|
Re: tests for context 'with stringify input set as true' do
let(:c_stringified) { Calculator.new(true) }
describe '#add' do
it 'should return a string' do
expect(c_stringified.add(1,3)).to be_kind_of(String)
end
end
describe '#subtract' do
it 'should return a string' do
expect(c_stringified.subtract(1,3)).to be_kind_of(String)
end
end
# and so on..
# ...
end |
|
Re: comment on line 55, square root of a perfect square should not have a decimal. Only non-round roots should have a decimal rounded up to 2 places, exactly. So, if |
No description provided.