Class: Tomo::Testing::CLITester

Inherits:
Object
  • Object
show all
Includes:
Local, LogCapturing
Defined in:
lib/tomo/testing/cli_tester.rb

Instance Method Summary collapse

Methods included from LogCapturing

#stderr, #stdout

Methods included from Local

#capture, capture, in_temp_dir, #with_tomo_gemfile, with_tomo_gemfile

Constructor Details

#initializeCLITester

Returns a new instance of CLITester.



11
12
13
# File 'lib/tomo/testing/cli_tester.rb', line 11

def initialize
  @token = SecureRandom.hex(8)
end

Instance Method Details

#in_temp_dirObject



15
16
17
# File 'lib/tomo/testing/cli_tester.rb', line 15

def in_temp_dir(&)
  super(token, &)
end

#run(*args, raise_on_error: true) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tomo/testing/cli_tester.rb', line 19

def run(*args, raise_on_error: true)
  in_temp_dir do
    restoring_defaults do
      capturing_logger_output do
        handling_exit(raise_on_error) do
          CLI.new.call(args.flatten)
        end
      end
    end
  end
end