Sha256: 543e47383215dbe192075c7fe525291293208567d421ec8e45991694e23f9562

Contents?: true

Size: 792 Bytes

Versions: 18

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

RSpec.describe(ScriptCore::ServiceChannel) do
  let(:writer) { instance_double(IO, "writer") }
  let(:reader) { instance_double(IO, "reader") }
  let(:service_channel) do
    ScriptCore::ServiceChannel.new(writer, reader)
  end

  it "forwards #write to the writer" do
    allow(writer).to receive(:write).and_return(writer)
    expect(service_channel.write("hello")).to eq(nil)
    expect(writer).to have_received(:write).with("hello")
  end

  it "rescues EPIPE from the writer" do
    expect(writer).to receive(:write).and_raise(Errno::EPIPE)
    expect(service_channel.write("hello")).to eq(nil)
  end

  it "forwards #read to the reader" do
    expect(reader).to receive(:read).and_return("hello")
    expect(service_channel.read).to eq("hello")
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
script_core-0.3.2 spec/script_core/service_channel_spec.rb
script_core-0.3.0 spec/script_core/service_channel_spec.rb
script_core-0.2.7 spec/script_core/service_channel_spec.rb
script_core-0.2.6 spec/script_core/service_channel_spec.rb
script_core-0.2.5 spec/script_core/service_channel_spec.rb
script_core-0.2.4 spec/script_core/service_channel_spec.rb
script_core-0.2.3 spec/script_core/service_channel_spec.rb
script_core-0.2.2 spec/script_core/service_channel_spec.rb
script_core-0.2.1 spec/script_core/service_channel_spec.rb
script_core-0.2.0 spec/script_core/service_channel_spec.rb
script_core-0.1.1 spec/script_core/service_channel_spec.rb
script_core-0.1.0 spec/script_core/service_channel_spec.rb
script_core-0.0.6 spec/script_core/service_channel_spec.rb
script_core-0.0.5 spec/script_core/service_channel_spec.rb
script_core-0.0.4 spec/script_core/service_channel_spec.rb
script_core-0.0.3 spec/script_core/service_channel_spec.rb
script_core-0.0.2 spec/script_core/service_channel_spec.rb
script_core-0.0.1 spec/script_core/service_channel_spec.rb