Sha256: 5e86bfe2b9f226d981fc90064527d92b4487414587956afb99f11ed94e9af003

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

RSpec.describe Mutant::Reporter::CLI::Tput do
  describe '.detect' do
    subject { described_class.detect }

    def expect_command(command, stdout, success)
      allow(Open3).to receive(:capture3).with(command).ordered.and_return(
        [
          stdout,
          double('Stderr'),
          double('Exitstatus', success?: success)
        ]
      )
    end

    let(:tput_reset?) { true }
    let(:tput_sc?)    { true }
    let(:tput_rc?)    { true }
    let(:tput_ed?)    { true }

    before do
      expect_command('tput reset', '[reset]', tput_reset?)
      expect_command('tput sc', '[sc]', tput_sc?)
      expect_command('tput rc', '[rc]', tput_rc?)
      expect_command('tput ed', '[ed]', tput_ed?)
    end

    context 'when all tput commands are supported' do
      its(:prepare) { should eql('[reset][sc]') }
      its(:restore) { should eql('[rc][ed]')    }
    end

    context 'when tput reset fails' do
      let(:tput_reset?) { false }

      it { should be(nil) }
    end

    context 'when ed fails' do
      let(:tput_ed?) { false }
      let(:tput_cd?) { true }
      before do
        expect_command('tput cd', '[cd]', tput_cd?)
      end
      its(:prepare) { should eql('[reset][sc]') }
      its(:restore) { should eql('[rc][cd]')    }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mutant-0.8.8 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.7 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.6 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.5 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.4 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.3 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.2 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.1 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.8.0 spec/unit/mutant/reporter/cli/tput_spec.rb
mutant-0.7.9 spec/unit/mutant/reporter/cli/tput_spec.rb