Sha256: 834aa0249421ba3b125b9e1ee2f435b98c326a7341d6687d325c2c02ab5e3916

Contents?: true

Size: 646 Bytes

Versions: 2

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

def suppress_stdout
  allow($stdout).to receive(:write)
end

def set_argv(*args)
  ARGV.replace(args)
end

def run(*args, fail_on_exit: true)
  set_argv(*args)

  begin
    Gistribute::CLI.new.run
  rescue SystemExit
    fail "unexpected exit" if fail_on_exit
  end
end

def simulate_user_input(*inputs)
  # The reference to `inputs` ends up getting stored in the mock, since
  # it's passed in with the block. Each time `gets` is called we pull
  # one off the beginning. If there aren't enough inputs, the error
  # gets raised.
  allow($stdin).to receive(:gets) { inputs.shift || fail("blocked for input") }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gistribute-0.3.1 spec/support/cli.rb
gistribute-0.3 spec/support/cli.rb