Module: Yes::Core::TestSupport::SubscriptionsHelper
- Includes:
- RSpec::Support::InSubProcess
- Defined in:
- lib/yes/core/test_support/subscriptions_helper.rb
Overview
RSpec helper for asserting that PgEventstore subscriptions start correctly.
Instance Method Summary collapse
-
#assert_running_subscriptions(*subscriptions_paths, number_of_subscriptions, root: './lib/tasks', timeout: 5) ⇒ void
Asserts that the expected number of subscriptions are running.
Instance Method Details
#assert_running_subscriptions(*subscriptions_paths, number_of_subscriptions, root: './lib/tasks', timeout: 5) ⇒ void
This method returns an undefined value.
Asserts that the expected number of subscriptions are running.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yes/core/test_support/subscriptions_helper.rb', line 31 def assert_running_subscriptions(*subscriptions_paths, number_of_subscriptions, root: './lib/tasks', timeout: 5) GRPC.prefork if defined?(GRPC) in_sub_process do GRPC.postfork_child if defined?(GRPC) setup_eventstore_cli = subscriptions_paths.flat_map { |path| ['-r', "#{root}/#{path}"] } runner = Thread.new { PgEventstore::CLI.execute(['subscriptions', 'start', *]) } subscriptions_count = poll_subscriptions(number_of_subscriptions, timeout) runner.exit aggregate_failures do expect(subscriptions_count['count_running']).to eq(number_of_subscriptions) expect(subscriptions_count['count_all']).to eq(number_of_subscriptions) end rescue StandardError => e Rails.logger.debug e. Rails.logger.debug e.backtrace raise e end nil ensure GRPC.postfork_parent if defined?(GRPC) end |