Sha256: b8b7bb132b364e53620681152dff7876bbf875c80fbeaba196d89148ce164519

Contents?: true

Size: 965 Bytes

Versions: 4

Compression:

Stored size: 965 Bytes

Contents

# coding: utf-8

RSpec.describe TTY::Pager::SystemPager, '#available' do
  let(:execs)   { ['less', 'more'] }

  subject(:pager) { described_class }

  it 'finds available command' do
    allow(pager).to receive(:executables).and_return(execs)
    allow(pager).to receive(:command_exists?).with('less') { true }
    allow(pager).to receive(:command_exists?).with('more') { false }
    expect(pager.available).to eql('less')
  end

  it "doesn't find command" do
    allow(pager).to receive(:executables).and_return(execs)
    allow(pager).to receive(:command_exists?) { false }
    expect(pager.available).to be_nil
  end

  it "takes precedence over other commands" do
    allow(pager).to receive(:command_exists?).with('more') { true }
    expect(pager.available('more')).to eql('more')
  end

  it "allows to query for available command" do
    allow(pager).to receive(:available).with('less') { true }
    expect(pager.available?('less')).to eq(true)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tty-pager-0.5.0 spec/unit/system/available_spec.rb
tty-pager-0.4.0 spec/unit/system/available_spec.rb
tty-pager-0.3.0 spec/unit/system/available_spec.rb
tty-pager-0.2.0 spec/unit/system/available_spec.rb