ruby - Rspec - expecting one among specific outputs -
working on rspec(2.14.1), rspec-core (2.14.8) & rspec-expectations(2.14.5) versions
need expect 1 of 2 specific outputs. tried below statements , got respective errors,
expect(fruit).should be_in('apple','mango')
error
nomethoderror: undefined method `should' #<rspec::expectations::expectationtarget:0x007fa63c4336d8>
and
expect(fruit).to eq('apple').or(eq('mango'))
and
expect(fruit).to include('apple').or(eq('mango'))
error
nomethoderror: undefined method `or' #<rspec::matchers::builtin::eq:0x007fa63c431630>
searched lot couldn't find solution. there way without having update rspec 3?
try this:
expect(fruit).to be_in(['apple','mango'])
you expecting element (fruit
) in array (['apple', 'mango']
)
Comments
Post a Comment