cli_spec.rb 972 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe BackgroundServices::Cli, ensure_threads_exited: true do
  4. context 'when invoking scripts/background-worker.rb via CLI' do
  5. context 'without arguments' do
  6. it 'shows a help screen' do
  7. expect { described_class.start([]) }.to output(%r{help \[COMMAND\]}).to_stdout
  8. end
  9. it 'returns success' do
  10. expect(described_class.start([])).to be_truthy
  11. end
  12. end
  13. context 'with wrong arguments' do
  14. it 'raises an error' do
  15. expect { ensure_block_keeps_running { described_class.start(['invalid-command-name']) } }.to raise_error(RuntimeError, 'Process tried to shut down unexpectedly.')
  16. end
  17. end
  18. context 'when running all services' do
  19. it 'starts scheduler correctly' do
  20. expect(ensure_block_keeps_running { described_class.start ['start'] }).to be(true)
  21. end
  22. end
  23. end
  24. end