質問

As for now I have something like this in my rspec test and it works fine:

expect{
 ...
}.to change(@foo_array.first, :bar).from(3.14).to(69)

But how to expect the change not only for .first but for every at @foo_array ?

Note: important is to don't execute ... commands multiple times

役に立ちましたか?

解決

How about:

count = @foo_array.count
expect{
 ...
}.to change(@foo_array.map(&:bar)).from([3.14]*count).to([69]*count)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top