Sha256: 4607e747f0552b137b6b2f6a44c9509276bc7d3c63f4da563801e07c2ba4791b

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'bacon'
require 'bacon/bits'
require 'mocha'
require 'mocha-on-bacon'
require 'bond'
require 'rbconfig'

module TestHelpers
  extend self
  def mock_irb
    unless Object.const_defined?(:IRB)
      eval %[
        module ::IRB
          class<<self; attr_accessor :CurrentContext; end
          module InputCompletor; CompletionProc = lambda {|e| [] }; end
        end
      ]
      ::IRB.CurrentContext = stub(:workspace=>stub(:binding=>binding))
    end
  end

  def capture_stderr(&block)
    original_stderr = $stderr
    $stderr = fake = StringIO.new
    begin
      yield
    ensure
      $stderr = original_stderr
    end
    fake.string
  end

  def capture_stdout(&block)
    original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
  end

  def tab(full_line, last_word=full_line)
    Bond.agent.weapon.stubs(:line_buffer).returns(full_line)
    Bond.agent.call(last_word)
  end

  def complete(*args, &block)
    Bond.complete(*args, &block)
  end

  def valid_readline_plugin
    Module.new{ def setup(arg); end; def line_buffer; end }
  end
end

class Bacon::Context
  include TestHelpers
end

# Default settings
Bond::M.debrief(:readline_plugin=>TestHelpers.valid_readline_plugin, :debug=>true)
include Bond

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bond-0.3.5 test/test_helper.rb
bond-0.3.4 test/test_helper.rb
bond-0.3.3 test/test_helper.rb
bond-0.3.2 test/test_helper.rb
bond-0.3.1 test/test_helper.rb
bond-0.3.0 test/test_helper.rb