Class: Methadone::BaseIntegrationTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FileUtils, IntegrationTestAssertions
Defined in:
lib/methadone/test/base_integration_test.rb

Instance Method Summary collapse

Methods included from IntegrationTestAssertions

#assert_banner, #assert_file, #assert_oneline_summary, #assert_option

Instance Method Details

#run_app(app_name, args, allow_failure: false) ⇒ Object

Run your app, capturing stdout, stderr, and process status.

app_name

Your bin name, without ‘bin/`

args

CLI args as a string

allow_failure

if true, this will return even if the app invocation fails. If false (the default), blows up if things go

wrong.



23
24
25
26
27
28
29
30
# File 'lib/methadone/test/base_integration_test.rb', line 23

def run_app(app_name, args, allow_failure: false)
  command = "bin/#{app_name} #{args}"
  stdout,stderr,results = Open3.capture3(command)
  if @allow_failure && !results.success?
    raise "'#{command}' failed!: #{results.inspect}\n\nSTDOUT {\n#{stdout}\n} STDERR {\n#{stderr}\n} END"
  end
  [stdout,stderr,results]
end