Sha256: 8040601d4724601990e2984b6692ca990ba730d3797adef1cc04bb02fb88c8b4

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

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

shared :underscore do
  should 'set _' do
    setup
    mock(@shell).get_input{'_'}
    mock(@shell).get_input{'10**2'}
    mock(@shell).get_input{'_'}
    @shell.loop_once.should.eq [nil, nil]
    @shell.loop_once
    @shell.loop_once.should.eq [100, nil]
  end

  should 'not set _ if already there' do
    bound = Object.new
    def bound._
      'hey'
    end
    setup(bound)
    mock(@shell).get_input{'_'}
    mock(@shell).get_input{'10**2'}
    mock(@shell).get_input{'_'}
    @shell.loop_once.should.eq ['hey', nil]
    @shell.loop_once
    @shell.loop_once.should.eq ['hey', nil]
  end

  should 'set __' do
    setup
    stub(@shell).puts{}.with_any_args
    mock(@shell).get_input{'XD'}
    mock(@shell).get_input{'__'}
    @shell.loop_once
    @shell.loop_once.first.should.kind_of?(NameError)
  end
end

describe Rib::Underscore do
  behaves_like :rib

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

  test_for Rib::Underscore do
    behaves_like :underscore
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rib-1.2.5 test/core/test_underscore.rb
rib-1.2.4 test/core/test_underscore.rb
rib-1.2.3 test/core/test_underscore.rb
rib-1.2.2 test/core/test_underscore.rb
rib-1.2.1 test/core/test_underscore.rb
rib-1.2.0 test/core/test_underscore.rb