سؤال

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