Sha256: cf10f179d83f76e6d591e9b65c3678f707fd95e3879bdc52610da0c5047a610b

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

RSpec.describe TTY::Pager, '.page' do
  let(:output) { StringIO.new }

  it "selects null pager when disabled" do
    null_pager = spy(:null_pager)
    allow(TTY::Pager::NullPager).to receive(:new) { null_pager }

    pager = described_class.new(enabled: false)
    text = "I try all things, I achieve what I can.\n"
    pager.page(text)

    expect(TTY::Pager::NullPager).to have_received(:new)
  end

  it "selects BasicPager when no paging command is available" do
    basic_pager = spy(:basic_pager)
    allow(TTY::Pager::SystemPager).to receive(:exec_available?) { false }
    allow(TTY::Pager::BasicPager).to receive(:new) { basic_pager }

    pager = described_class.new
    text = "I try all things, I achieve what I can.\n"
    pager.page(text)

    expect(basic_pager).to have_received(:page).with(text)
  end

  it "selects SystemPager when paging command is available" do
    system_pager = spy(:system_pager)
    allow(TTY::Pager::SystemPager).to receive(:exec_available?) { true }
    allow(TTY::Pager::SystemPager).to receive(:new) { system_pager }

    pager = described_class.new
    text = "I try all things, I achieve what I can.\n"
    pager.page(text)

    expect(system_pager).to have_received(:page).with(text)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-pager-0.11.0 spec/unit/page_spec.rb