debian-mirror-gitlab/spec/support/helpers/expect_next_instance_of.rb

16 lines
387 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module ExpectNextInstanceOf
def expect_next_instance_of(klass, *new_args)
receive_new = receive(:new)
receive_new.with(*new_args) if new_args.any?
expect(klass).to receive_new
.and_wrap_original do |method, *original_args|
method.call(*original_args).tap do |instance|
yield(instance)
end
end
end
end