Sha256: 5c19c7400ac3afe1d5ae6c64ad9c84520f631ad179d976886ab638780874e9a6

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

require 'rib/test'
require 'rib/core/underscore'

describe Rib::Underscore do
  behaves_like :rib

  before do
    Rib::Underscore.enable
  end

  def setup bound=Object.new
    @shell = Rib::Shell.new(
      :binding => bound.instance_eval{binding}).before_loop
  end

  should 'set _' do
    setup
    @shell.eval_input('_').should.eq nil
    @shell.eval_input('10 ** 2')
    @shell.eval_input('_').should.eq 100
  end

  should 'not set _ if already there' do
    bound = Object.new
    def bound._
      'hey'
    end
    setup(bound)
    @shell.eval_input('_').should.eq 'hey'
    @shell.eval_input('10 ** 2')
    @shell.eval_input('_').should.eq 'hey'
  end

  should 'set __' do
    setup
    stub(@shell).warn
    @shell.eval_input('XD')
    @shell.eval_input('__').should.kind_of?(NameError)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rib-0.1.0 test/core/test_underscore.rb