Sha256: 39814fb53b578e385a3d20857f9e4280819dcc88fef2f7151c9012ad0d2fb5ec

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8

RSpec.describe TTY::Screen, '.new' do

  it "initializses size with defaults" do
    allow(TTY::Screen::Size).to receive(:new)
    TTY::Screen.new
    expect(TTY::Screen::Size).to have_received(:new).
      with(ENV, {output: $stderr, verbose: false})
  end

  it "initializes size with values" do
    allow(TTY::Screen::Size).to receive(:new)

    TTY::Screen.new(output: :output, verbose: true)

    expect(TTY::Screen::Size).to have_received(:new).
      with(ENV, output: :output, verbose: true)
  end

  it "delegates size call" do
    size_instance = spy(:size)
    allow(TTY::Screen::Size).to receive(:new).and_return(size_instance)

    screen = described_class.new
    screen.size

    expect(size_instance).to have_received(:size)
  end

  it "calls size" do
    size_instance = double(:size, size: [51, 280])
    allow(TTY::Screen::Size).to receive(:new).and_return(size_instance)

    expect(TTY::Screen.size).to eq([51, 280])
    expect(TTY::Screen::Size).to have_received(:new).once
  end

  it "calls width" do
    size_instance = double(:size, size: [51, 280])
    allow(TTY::Screen::Size).to receive(:new).and_return(size_instance)

    expect(TTY::Screen.width).to eq(280)
    expect(TTY::Screen::Size).to have_received(:new).once
  end

  it "calls height" do
    size_instance = double(:size, size: [51, 280])
    allow(TTY::Screen::Size).to receive(:new).and_return(size_instance)
    expect(TTY::Screen.height).to eq(51)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-screen-0.5.0 spec/unit/new_spec.rb