我正在尝试测试一个数组是否包含另一个(rspec 2.11.0)
test_arr = [1, 3]
describe [1, 3, 7] do
it { should include(1,3) }
it { should eval("include(#{test_arr.join(',')})")}
#failing
it { should include(test_arr) }
end
这是结果 rspec spec/test.spec ..F
Failures:
1) 1 3 7
Failure/Error: it { should include(test_arr) }
expected [1, 3, 7] to include [1, 3]
# ./spec/test.spec:7:in `block (2 levels) in <top (required)>'
Finished in 0.00125 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/test.spec:7 # 1 3 7
include rspec 方法不接受数组参数,有更好的方法来避免“eval”吗?