davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

Support aruba running the methadone App in-process #96

Closed delitescere closed 6 years ago

delitescere commented 8 years ago

Aruba allows you to run apps in-process which is faster and also lets you do something like set the system date (as far as Ruby is concerned) to a specific value.

I've been trying to get this to work with some hacking but it'd be superb if methadone supported it out of the gate.

blysik commented 8 years ago

I think this would also allow using webmock to stub remote APIs, per this blog post: http://georgemcintosh.com/vcr-and-aruba/

I have a methadone app which makes a call against a remote API, and I can't find any way to use webmock to stub the responses.

blysik commented 8 years ago

To go into more detail, I'm trying something like this:

class WebmockFriendlyMain
  def initialize(argv, stdin, stdout, stderr, kernel)
    @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
  end

  def execute!
    $stdin = @stdin
    $stdout = @stdout
    App.go!(@argv)
  end
end
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')

Before do
  # Using "announce" causes massive warnings on 1.9.2
  @puts = true
  @original_rubylib = ENV['RUBYLIB']
  ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s

  Aruba::InProcess.main_class = WebmockFriendlyMain
  Aruba.process = Aruba::InProcess
end

After do
  ENV['RUBYLIB'] = @original_rubylib
  Aruba.process = Aruba::SpawnProcess
  $stdin = STDIN
  $stdout = STDOUT
end

But App.go! isn't correct.

davetron5000 commented 6 years ago

When #121 is merged, Cucumber/Aruba will no longer be supported, as I was unable to get the latest versions to work with this app at all. That change includes more direct integration testing support via test::unit