Sha256: 8fd983ab2c287d924cf23fc77e5ced849d82b9e8cde6e856c25cdd5fd1b28be0

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require 'boson/console'
require File.join(File.dirname(__FILE__), 'test_helper')

# TODO: fix default_libraries picking up local defaults
describe "repl_runner" do
  def start(hash={})
    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 }

  # TODO: fix
  xdescribe "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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
boson-more-0.3.1 test/todo/console_test.rb
boson-more-0.3.0 test/todo/console_test.rb
boson-more-0.2.2 test/todo/console_test.rb