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 Rakshit

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

···

Am 08.05.2014 14:46, schrieb Arup Rakshit:

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

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A