Module: Minitest::Docker::Compose
- Defined in:
- lib/minitest/docker/compose.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #run_command(command, env = {}) ⇒ Object
- #run_command!(command, env = {}) ⇒ Object
- #verbose? ⇒ Boolean
- #wait! ⇒ Object
Class Method Details
.prepended(klass) ⇒ Object
6 7 8 |
# File 'lib/minitest/docker/compose.rb', line 6 def self.prepended(klass) klass.extend(ClassMethods) end |
Instance Method Details
#run_command(command, env = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/minitest/docker/compose.rb', line 45 def run_command(command, env = {}) env = Minitest::Docker.default_env.merge(env) Dir.chdir(Minitest::Docker.app_dir) do command_output = '' puts "Running #{command} with #{env.inspect}" if verbose? status = Open3.popen2e(ENV.to_hash.merge(env), *command) do |input, output, wait_thread| input.close output.each(56) do |out| command_output << out print out if verbose? end wait_thread.value end [status.success?, command_output] end end |
#run_command!(command, env = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/minitest/docker/compose.rb', line 37 def run_command!(command, env = {}) run_command(command, env).tap do |status, output| unless status raise CommandError.new(command, output) end end end |
#verbose? ⇒ Boolean
23 24 25 |
# File 'lib/minitest/docker/compose.rb', line 23 def verbose? ENV['VERBOSE'] end |
#wait! ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/minitest/docker/compose.rb', line 27 def wait! return unless Minitest::Docker.wait_command Timeout.timeout(10) do until run_command(Minitest::Docker.wait_command).first sleep 0.3 end end end |