tty-pager 0.9.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,50 +0,0 @@
1
- # coding: utf-8
2
-
3
- RSpec.describe TTY::Pager::SystemPager, '#available' do
4
- let(:execs) { ['less', 'more'] }
5
-
6
- subject(:pager) { described_class }
7
-
8
- it 'finds available command' do
9
- allow(pager).to receive(:executables).and_return(execs)
10
- allow(pager).to receive(:command_exists?).with('less') { true }
11
- allow(pager).to receive(:command_exists?).with('more') { false }
12
- expect(pager.available).to eql('less')
13
- end
14
-
15
- it "doesn't find command" do
16
- allow(pager).to receive(:executables).and_return(execs)
17
- allow(pager).to receive(:command_exists?) { false }
18
- expect(pager.available).to be_nil
19
- end
20
-
21
- it "takes precedence over other commands" do
22
- allow(pager).to receive(:command_exists?).with('more') { true }
23
- expect(pager.available('more')).to eql('more')
24
- end
25
-
26
- it "allows to query for available command" do
27
- allow(pager).to receive(:available).with('less') { true }
28
- expect(pager.available?('less')).to eq(true)
29
- end
30
-
31
- context "when given nil, blank, and whitespace commands" do
32
- let(:execs) { [nil, "", " ", "less"] }
33
-
34
- it "does not error" do
35
- allow(pager).to receive(:executables).and_return(execs)
36
- allow(pager).to receive(:command_exists?).with('less') { true }
37
- expect(pager.available).to eql('less')
38
- end
39
- end
40
-
41
- context "when given a multi-word executable" do
42
- let(:execs) { ["diff-so-fancy | less --tabs=4 -RFX"] }
43
-
44
- it "finds the command" do
45
- allow(pager).to receive(:executables).and_return(execs)
46
- allow(pager).to receive(:command_exists?).with("diff-so-fancy") { true }
47
- expect(pager.available).to eql(execs.first)
48
- end
49
- end
50
- end
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
-
3
- RSpec.describe TTY::Pager::SystemPager, '#command_exists?' do
4
- subject(:pager) { described_class }
5
-
6
- it "successfully checks command exists on the system" do
7
- allow(TTY::Which).to receive(:exist?).with('less').and_return('/usr/bin/less').and_return(true)
8
- expect(pager.command_exists?('less')).to eq(true)
9
- end
10
-
11
- it "fails to check command exists on the system" do
12
- allow(TTY::Which).to receive(:exist?).with('less').and_return(false)
13
- expect(pager.command_exists?('less')).to eq(false)
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- RSpec.describe TTY::Pager::SystemPager, '#new' do
4
- it "raises error if system paging is not supported" do
5
- allow(TTY::Pager::SystemPager).to receive(:available?).and_return(false)
6
- expect {
7
- TTY::Pager::SystemPager.new
8
- }.to raise_error(TTY::Pager::Error, "TTY::Pager::SystemPager cannot be used on your system due to lack of appropriate pager executable. Install `less` like pager or try using `BasicPager` instead.")
9
- end
10
- end
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
-
3
- RSpec.describe TTY::Pager::SystemPager, '.page' do
4
- it "executes the pager command in a subprocess" do
5
- text = "I try all things, I achieve what I can.\n"
6
- allow(TTY::Pager::SystemPager).to receive(:available?).and_return(true)
7
- output = double(:output, :tty? => true)
8
- pager = described_class.new(output: output)
9
- write_io = spy
10
- pid = 12345
11
-
12
- allow(pager).to receive(:open).and_return(write_io)
13
- allow(write_io).to receive(:pid).and_return(pid)
14
- status = double(:status, :success? => true)
15
- allow(Process).to receive(:waitpid2).with(pid, any_args).and_return([1, status])
16
-
17
- expect(pager.page(text)).to eq(true)
18
- expect(write_io).to have_received(:write).with(text)
19
- expect(write_io).to have_received(:close)
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Load gem inside irb console'
4
- task :console do
5
- require 'irb'
6
- require 'irb/completion'
7
- require File.join(__FILE__, '../../lib/tty-pager')
8
- ARGV.clear
9
- IRB.start
10
- end
11
- task :c => :console
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Measure code coverage'
4
- task :coverage do
5
- begin
6
- original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
- Rake::Task['spec'].invoke
8
- ensure
9
- ENV['COVERAGE'] = original
10
- end
11
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require 'rspec/core/rake_task'
5
-
6
- desc 'Run all specs'
7
- RSpec::Core::RakeTask.new(:spec) do |task|
8
- task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
9
- end
10
-
11
- namespace :spec do
12
- desc 'Run unit specs'
13
- RSpec::Core::RakeTask.new(:unit) do |task|
14
- task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
15
- end
16
-
17
- desc 'Run integration specs'
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
20
- end
21
- end
22
-
23
- rescue LoadError
24
- %w[spec spec:unit spec:integration].each do |name|
25
- task name do
26
- $stderr.puts "In order to run #{name}, do `gem install rspec`"
27
- end
28
- end
29
- end
@@ -1,28 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'tty/pager/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "tty-pager"
8
- spec.version = TTY::Pager::VERSION
9
- spec.authors = ["Piotr Murach"]
10
- spec.email = [""]
11
- spec.summary = %q{Terminal output paging in a cross-platform way supporting all major ruby interpreters.}
12
- spec.description = %q{Terminal output paging in a cross-platform way supporting all major ruby interpreters.}
13
- spec.homepage = "https://github.com/piotrmurach/tty-pager"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency 'tty-screen', '~> 0.5.0'
22
- spec.add_dependency 'tty-which', '~> 0.3.0'
23
- spec.add_dependency 'verse', '~> 0.5.0'
24
-
25
- spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
26
- spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'rspec', '~> 3.6.0'
28
- end