Sha256: db63a464210f7dfb6da1c2962cbf6195a63886611976baa744c1a315c238846f

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 KB

Contents

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

shared :squeeze_history do
  should 'after_loop saves squeezed history' do
    @shell.history.push(*@input)
    @shell.after_loop
    File.read(@history).should.eq %w[foo bar foo bar].join("\n") + "\n"
  end

  should 'loop_once squeeze history' do
    times = @input.size
    stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'")[-1] }
    stub(@shell).print_result
    times.times{ @shell.loop_once }
    @shell.history.to_a.should.eq %w[foo bar foo bar].map{ |i| "'#{i}'" }
  end

  should 'be disabled if disabled' do
    Rib::SqueezeHistory.disable
    times = @input.size
    input = @input.dup
    stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'")[-1] }
    stub(@shell).print_result
    times.times{ @shell.loop_once }
    @shell.history.to_a.should.eq input.map{ |i| "'#{i}'" }
    Rib::SqueezeHistory.enable
  end
end

describe Rib::SqueezeHistory do
  behaves_like :rib

  before do
    @history = "/tmp/test_rib_#{rand}"
    @shell   = Rib::Shell.new(:history_file => @history).before_loop
    @input   = %w[foo bar bar foo bar]
    clear_history(@shell.history)
  end

  after do
    FileUtils.rm_f(@history)
  end

  test_for Rib::History, Rib::SqueezeHistory do
    behaves_like :squeeze_history
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rib-1.1.3 test/core/test_squeeze_history.rb
rib-1.1.2 test/core/test_squeeze_history.rb
rib-1.1.1 test/core/test_squeeze_history.rb
rib-1.1.0 test/core/test_squeeze_history.rb
rib-1.0.5 test/core/test_squeeze_history.rb
rib-1.0.4 test/core/test_squeeze_history.rb
rib-1.0.3 test/core/test_squeeze_history.rb
rib-1.0.2 test/core/test_squeeze_history.rb
rib-1.0.1 test/core/test_squeeze_history.rb
rib-1.0.0 test/core/test_squeeze_history.rb
rib-0.9.9 test/core/test_squeeze_history.rb
rib-0.9.5 test/core/test_squeeze_history.rb
rib-0.9.5.pre.1 test/core/test_squeeze_history.rb
rib-0.9.5.pre.0 test/core/test_squeeze_history.rb
rib-0.9.4 test/core/test_squeeze_history.rb
rib-0.9.3 test/core/test_squeeze_history.rb
rib-0.9.2 test/core/test_squeeze_history.rb
rib-0.9.1 test/core/test_squeeze_history.rb