Sha256: 200fe31445a9792d0580035ed869af1438fcec2e103950239128dc45cedfa7ad

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe UV::TTY do
  let(:handle_name) { :tty }
  let(:loop) { double() }
  let(:pointer) { double() }
  subject { UV::TTY.new(loop, pointer) }

  it_behaves_like 'a handle'
  it_behaves_like 'a stream'

  describe "#enable_raw_mode" do
    it "calls UV.tty_set_mode" do
      UV.should_receive(:tty_set_mode).with(pointer, 1)

      subject.enable_raw_mode
    end
  end

  describe "#disable_raw_mode" do
    it "calls UV.tty_set_mode" do
      UV.should_receive(:tty_set_mode).with(pointer, 0)

      subject.disable_raw_mode
    end
  end

  describe "#reset_mode" do
    it "calls UV.tty_reset_mode" do
      UV.should_receive(:tty_reset_mode)

      subject.reset_mode
    end
  end

  describe "#winsize" do
    let(:width) { 100 }
    let(:height) { 100 }
    let(:width_pointer) { double() }
    let(:height_pointer) { double() }

    it "calls UV.tty_get_winsize" do
      FFI::MemoryPointer.should_receive(:new).once.with(:int).and_return(width_pointer)
      FFI::MemoryPointer.should_receive(:new).once.with(:int).and_return(height_pointer)
      width_pointer.should_receive(:get_int).with(0).and_return(width)
      height_pointer.should_receive(:get_int).with(0).and_return(height)

      UV.should_receive(:tty_get_winsize).with(pointer, width_pointer, height_pointer)

      subject.winsize.should == [width, height]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uvrb-0.2.0 spec/uv/tty_spec.rb
uvrb-0.1.4 spec/uv/tty_spec.rb
uvrb-0.1.3 spec/uv/tty_spec.rb
uvrb-0.1.2 spec/uv/tty_spec.rb
uvrb-0.1.1 spec/uv/tty_spec.rb
uvrb-0.1.0 spec/uv/tty_spec.rb