summaryrefslogtreecommitdiff
path: root/spec/support/shell_helpers.rb
blob: c22da0ea1ff634420556ef353d868ab500436475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'English'

RSpec.shared_context 'when executing the cli' do
  subject { execute(command) }

  let(:status) { subject[0] }
  let(:output) { subject[1] }
  let(:env) {}

  def execute(command, mute: false, env: self.env)
    full_command = "#{env} ./exe/saml-kit #{command} 2>&1"
    puts full_command unless mute
    output = `#{full_command}`
    [$CHILD_STATUS, output]
  end
end

RSpec.configure do |config|
  config.include_context 'when executing the cli'
end