Sha256: 4c529cad4a86107c489eb9dc627bdcc5fe5c1df6dfb1a9f3f10233d3b5f933c7

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

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

class Bond::MissionTest < Test::Unit::TestCase
  before(:all) {|e| Bond.debrief(:readline_plugin=>valid_readline_plugin) }

  context "mission" do
    before(:each) {|e| Bond.agent.instance_eval("@missions = []") }
    test "completes" do
      Bond.complete(:on=>/bling/) {|e| %w{ab cd fg hi}}
      Bond.complete(:method=>'cool') {|e| [] }
      complete('some bling f').should == %w{fg}
    end

    test "with method completes" do
      Bond.complete(:on=>/bling/) {|e| [] }
      Bond.complete(:method=>'cool') {|e| %w{ab cd ef gd} }
      complete('cool c').should == %w{cd}
    end

    test "with method and quoted argument completes" do
      Bond.complete(:on=>/bling/) {|e| [] }
      Bond.complete(:method=>'cool') {|e| %w{ab cd ef ad} }
      complete('cool "a').should == %w{ab ad}
    end

    test "with string method completes exact matches" do
      Bond.complete(:method=>'cool?') {|e| [] }
      Bond.complete(:method=>'cool') {|e| %w{ab cd ef gd} }
      complete('cool c').should == %w{cd}
    end

    test "with regex method completes multiple methods" do
      Bond.complete(:method=>/cool|ls/) {|e| %w{ab cd ef ad}}
      complete("cool a").should == %w{ab ad}
      complete("ls c").should == %w{cd}
    end

    test "with regexp condition completes" do
      Bond.complete(:on=>/\s*'([^']+)$/, :search=>false) {|e| %w{coco for puffs}.grep(/#{e.matched[1]}/) }
      complete("require 'ff").should == ['puffs']
    end

    test "with non-string completions completes" do
      Bond.complete(:on=>/.*/) { [:one,:two,:three] }
      complete('ok ').should == %w{one two three}
    end
  end

  test "default_mission set to a valid mission if irb doesn't exist" do
    Object.expects(:const_defined?).with(:IRB).returns(false)
    mission = Bond::Missions::DefaultMission.new
    mission.action.respond_to?(:call).should == true
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
cldwalker-bond-0.1.1 test/mission_test.rb
bond-0.1.1 test/mission_test.rb