Sha256: 469a12f84e92db452319660a49c4634779a92cc7af6a94f8addef7f36d7ef9d0

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

require 'open3'

describe Endoscope do
  it 'has a version number' do
    expect(Endoscope::VERSION).not_to be nil
  end

  context "with a patient process running the Endoscope agent" do
    let(:bin) { File.expand_path("../../bin", __FILE__) }

    before do
      @patient = IO.popen(File.join(bin, 'patient'))
    end

    after do
      Process.kill "TERM", @patient.pid
    end

    it 'allows an endoscope process to evaluate ruby code inside of a patient process and show the result' do
      q = Queue.new

      Open3.popen2(File.join(bin, 'endoscope')) do |endo_in, endo_out, _endo_wait|
        Thread.new { endo_out.each_line { |l| q.push l.chomp } }

        endo_in.puts "$0"

        Timeout.timeout(5) do
          expect(q.pop).to eql ">> $0" # user input
          expect(q.pop).to eql ">> Sending command $0..."  # command confirmation
          expect(q.pop).to eql "From patient.1 :"          # response banner
          expect(q.pop).to include "endoscope/bin/patient" # response contents
        end
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
endoscope-0.0.1 spec/endoscope_spec.rb