Closed delitescere closed 6 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.
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.
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
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.