开发者

Testing Array membership in rspec

开发者 https://www.devze.com 2023-04-11 17:46 出处:网络
I\'d like to test whether or not an array contains a given object. I suppose I co开发者_StackOverflowuld accomplish this with

I'd like to test whether or not an array contains a given object.

I suppose I co开发者_StackOverflowuld accomplish this with

some_array.index(object).should be_a_kind_of(Integer)

or

some_array.index(object).should_not be_nil

or

some_array.include?(object).should be_true

However, I'm hoping there's a more elegant way to express this, something like

some_array.should include(object)

but, you know, valid code. Is there?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号