Rspec for conditional code if-else

Hi,

What will be the way to write a test code :

def meth(arg)
arg == 2
end

if meth(val)
call_meth1
else
call_meth2
end

Regards,
Arup R.

Am 08.05.2014 14:46, schrieb Arup R.:

end
That’s not the right question to ask.

You should not write tests for “if-else” or for “Enumerable#any?” etc.
but instead decide what the desired behaviour of your method is for
a given set of preconditions, and test for that behaviour.

It might also be useful to look into the rspec files of some
open source projects as an example.

Regards,
Marcus

Well, as the unkown guy says you should read RSpec book. But you should
think like this:

def meth(arg)
arg == 2
end

meth(2).should be true
meth(5).should be false