如何描述RSpec测试以检查阵列是否包含某些值?像这样的东西:
tags.should include("one")
tags.should not include("two")
Run Code Online (Sandbox Code Playgroud)
我可以改写我的条件:
tags.include?("two").should be_false
Run Code Online (Sandbox Code Playgroud)
但我正在寻找更美丽的解决方案.
Ale*_*ski 15
for Rspec v3:
expect(my_string).to include "some value"
expect(my_string).not_to include "some value"
Run Code Online (Sandbox Code Playgroud)
RSpec的有should_not以及should.
tags.should include("one")
tags.should_not include("two")
Run Code Online (Sandbox Code Playgroud)
这里有一些包含匹配器的例子.