Sha256: 1955a78fc3fcb876653fb47d58aa99ba7d5a7d2187b9d0a6d0646c8c16c14b99

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe "repl_runner" do
  def start(hash={})
    Hirb.stubs(:enable)
    Boson.start(hash.merge(:verbose=>false))
  end

  before_all { reset }
  before { ConsoleRunner.instance_eval("@initialized = false") }

  it "loads default libraries and libraries in :console_defaults config" do
    defaults = BareRunner.default_libraries + ['yo']
    with_config(:console_defaults=>['yo']) do
      Manager.expects(:load).with {|*args| args[0] == defaults }
      start
    end
  end

  it "doesn't call init twice" do
    capture_stderr { start }
    ConsoleRunner.expects(:init).never
    start
  end

  it "loads multiple libraries with :libraries option" do
    ConsoleRunner.expects(:init)
    Manager.expects(:load).with([:lib1,:lib2], anything)
    start(:libraries=>[:lib1, :lib2])
  end

  it "autoloader autoloads libraries" do
    start(:autoload_libraries=>true)
    Index.expects(:read)
    Index.expects(:find_library).with('blah').returns('blah')
    Manager.expects(:load).with('blah', anything)
    Boson.main_object.blah
  end
  after_all { FileUtils.rm_r File.dirname(__FILE__)+'/config', :force=>true }
end

describe "console options" do
  before_all { reset }

  it "console option starts irb" do
    ConsoleRunner.expects(:start)
    Util.expects(:which).returns("/usr/bin/irb")
    ConsoleRunner.expects(:load_repl).with("/usr/bin/irb")
    start("--console")
  end

  it "console option but no irb found prints error" do
    ConsoleRunner.expects(:start)
    Util.expects(:which).returns(nil)
    ConsoleRunner.expects(:abort).with {|arg| arg[/Console not found/] }
    start '--console'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
boson-more-0.2.1 test/console_runner_test.rb
boson-more-0.2.0 test/console_runner_test.rb
boson-more-0.1.0 test/console_runner_test.rb