Sha256: 5a5c7d6caf35e39a9a67d6406abc0072ee1cd8c07f10261110aa1a416d43028c

Contents?: true

Size: 515 Bytes

Versions: 1

Compression:

Stored size: 515 Bytes

Contents

require 'spec_helper'

describe Redcap do
  describe '.pid_for_port' do
    let(:socket) {
      double('socket', :write => nil, :read => '42', :close => nil)
    }

    before :each do
      allow(TCPSocket).to receive(:new).and_return(socket)
    end

    it "sends the given port to the socket" do
      expect(socket).to receive(:write).with("101\n")

      Redcap.pid_for_port(101)
    end

    it "returns the socket output as an integer" do
      expect(Redcap.pid_for_port(101)).to eq(42)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redcap-0.2.0 spec/redcap_spec.rb