File: cli_parsing.rb

package info (click to toggle)
ruby-puppetserver-ca-cli 2.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 696 kB
  • sloc: ruby: 6,970; sh: 4; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
RSpec.shared_examples 'basic cli args' do |action, usage|
  let(:stdout) { StringIO.new }
  let(:stderr) { StringIO.new }

  it 'responds to a --help flag' do
    args = [action, '--help'].compact
    exit_code = Puppetserver::Ca::Cli.run(args, stdout, stderr)
    expect(stdout.string).to match(usage)
    expect(exit_code).to be 0
  end

  it 'prints the version' do
    semverish = /\d+\.\d+\.\d+(-[a-z0-9._-]+)?/
    args = [action, '--version'].compact
    first_code = Puppetserver::Ca::Cli.run(args, stdout, stderr)
    expect(stdout.string).to match(semverish)
    expect(stderr.string).to be_empty
    expect(first_code).to be 0
  end
end