Sha256: 3d32cd992ba627178dd7854792fece571eaf6e55c94418f2829d809e4ebb1398

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'rib/test'
require 'rib/test/history'
require 'rib/core/squeeze_history'

describe Rib::SqueezeHistory do
  paste :rib

  test_for Rib::History, Rib::SqueezeHistory do
    paste :setup_history

    before do
      @input = %w[foo bar bar foo bar]
    end

    would 'after_loop saves squeezed history' do
      shell.history.push(*@input)
      shell.after_loop

      expect(File.read(history_file)).eq %w[foo bar foo bar].join("\n") + "\n"
    end

    would 'loop_once squeeze history' do
      stub_output
      stub(shell).get_input{ (shell.history << "'#{@input.shift}'").last }

      @input.size.times{ shell.loop_once }

      expect(shell.history.to_a).eq %w[foo bar foo bar].map{ |i| "'#{i}'" }
    end

    would 'be disabled if disabled' do
      Rib::SqueezeHistory.disable do
        stub_output
        stub(shell).get_input{ (shell.history << "'#{@input.shift}'").last }
        input = @input.dup

        @input.size.times{ shell.loop_once }

        expect(shell.history.to_a).eq input.map{ |i| "'#{i}'" }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rib-1.5.4 test/core/test_squeeze_history.rb
rib-1.5.3 test/core/test_squeeze_history.rb
rib-1.5.2 test/core/test_squeeze_history.rb