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