Welcome to mirror list, hosted at ThFree Co, Russian Federation.

expect_next_instance_of.rb « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 749d2cb2a5697604975b704f35c38fd8ba7176c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

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