I have a function func that returns an array with two arguments which I normally use as follows:
heads, tails = func
so in an rspec test, I would like to write
let(:heads, :tails, :draw){ func }
but this raises an exception. I know I can just put
let(:ans){ func }
let(:heads){ ans.first }
let(:tails){ ans.second }
Is there an easier way to do this in rspec. If not, is there a method call that I can write that do this for me e.g.
def let_multi(f)
let(:ans){ f }
let(:heads){ ans.first }
let(:tails){ ans.second }
end
and then in the test
let_multi func
My attempt with let_multi func does not work because func is only defined in an it block.