Hi, I am currently learning Ruby as much as i can (non rails usage) and
have a quick question about Rspec (and it is properly a more general TDD
question).
If you have class for example:
class MyClass
def foo(value)
#do someting
end
def bar(value)
#do something
end
def spam
a = foo(“value”)
b = bar(“value”)
end
end
If you were testing this class how would you go about it?
In my mind i would test foo and make sure it returns what i expect
I would also test bar to make sure it returns what i expect.
But also in my mind, i feel like when i test spam, that it calls out to
foo and bar.
Am I getting this wrong? should i be testing spam to also make sure that
it returns what i expect, regardless of wether it has made a call to foo
or bar?
I know i can stub the foo and bar methods for the test of spam to
control what spam can and wont return.
If anyone could help me get past this “final” hurdle in my understanding
of testing, and TDD i would be most grateful.
Thanks
Ps: i couldnt work out how to format my message sorry!