3
如何描述RSpec测试以检查数组是否不包含某个值?事情是这样的:不应该包含
tags.should include("one")
tags.should not include("two")
我可以重写我的条件:
tags.include?("two").should be_false
,但我正在寻找更漂亮的解决方案。
如何描述RSpec测试以检查数组是否不包含某个值?事情是这样的:不应该包含
tags.should include("one")
tags.should not include("two")
我可以重写我的条件:
tags.include?("two").should be_false
,但我正在寻找更漂亮的解决方案。
RSpec有should_not
以及should
。
tags.should include("one")
tags.should_not include("two")
这里有一些more examples的包括匹配器。
:
expect(my_string).to include "some value"
expect(my_string).not_to include "some value"
现在这是优于'should'语法。 – theUtherSide 2017-09-13 18:42:00