ruby - VoltRB rspec testing a method can't convert Promise into Array -
i trying rspec unit tests on method in model. method returns promise, , when resolved, name of person. method not problem know works correctly. here test code:
it 'should return correct name' report = report.new(first_name: 'testy', last_name: 'testerson') report.save! expect(report.name).to eql('testy testerson') end
when test it, following error:
failure/error: expect(report.name).to eql('testy testerson') typeerror: can't convert promise array (promise#to_ary gives promise)
while debugging, used following line inspect returned value of method:
puts report.name.inspect
and got following response:
#<promise(70319926955580): "testy testerson">
the error seems happening because tests promise against expected value. why getting error?
using report.name.value fixes issue
Comments
Post a Comment