2012-03-28 85 views
3

如何描述RSpec测试以检查数组是否不包含某个值?事情是这样的:不应该包含

tags.should include("one") 
tags.should not include("two") 

我可以重写我的条件:

tags.include?("two").should be_false 

,但我正在寻找更漂亮的解决方案。

回答

7

RSpec有should_not以及should

tags.should include("one") 
tags.should_not include("two") 

这里有一些more examples的包括匹配器。

8
对Rspec的V3

expect(my_string).to include "some value" 


expect(my_string).not_to include "some value" 
+0

现在这是优于'should'语法。 – theUtherSide 2017-09-13 18:42:00

相关问题