我希望编写如下代码:
range = (1..10)
regex = /[a-z]/
expect(range).to ===(5)
expect(regex).to ===('a')
感谢。
答案 0 :(得分:1)
要使用运算符,请使用be
:
describe :something do
it 'works just fine' do
expect((1..10)).to be === 5
end
it 'works fine too' do
expect(/[a-z]/).to be === 'a'
end
end
但Regex有更多具体选项:
expect(/[a-z]/).to match('a')
对于Ranges:
expect(1..10).to cover(5)