Today I Learned

Ruby on Rails with RSpec - yielding multiple arguments

If you are yielding many things in one yield statement, for instance:

def each
  author.books.each do |book|
    yield BookDecorator.new(book), EpicBookDecorator.new(book)
  end
end

you are able to test it in RSpec using yield_successive_args with arguments packed within an array:

expect { |b| book_collection.each(&b) }.to yield_successive_args(
  [book_decorator1, epic_book_decorator1],
  [book_decorator2, epic_book_decorator2]
)