2012-03-28 50 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

相關問題