Sha256: 896c639e7eb109a8211791bc26d2261d7126a66a336c4bc3fecd98f8b55692ea

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

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

describe "ObjectMission" do
  before { Bond.agent.reset }
  describe "object mission" do
    it "with default action completes" do
      complete(:object=>"String")
      complete(:on=>/man/) { %w{upper upster upful}}
      tab("'man'.up").sort.should == [".upcase", ".upcase!", ".upto"]
    end

    it "with regex condition completes" do
      complete(:object=>'Str.*') {|e| e.object.class.superclass.instance_methods(true) }
      complete(:on=>/man/) { %w{upper upster upful}}
      tab("'man'.unta").should == [".untaint"]
    end

    it "with explicit action completes" do
      complete(:object=>"String") {|e| e.object.class.superclass.instance_methods(true) }
      complete(:on=>/man/) { %w{upper upster upful}}
      tab("'man'.unta").should == [".untaint"]
    end

    it "completes without including word break characters" do
      complete(:object=>"Hash")
      matches = tab("{}.f")
      matches.size.should.be > 0
      matches.all? {|e| !e.include?('{')}.should == true
    end

    it "completes with additional text after completion point" do
      complete(:object=>"Object")
      tab(':man.f blah', ':man.f').include?(':man.freeze').should == true
    end

    it "doesn't evaluate anything before the completion object" do
      complete(:object=>'Object')
      tab('raise :man.i').size.should > 0
    end

    it "ignores invalid ruby" do
      complete(:object=>"String")
      tab("blah.upt").should == []
    end

    it "ignores object that doesn't have a valid class" do
      complete :on=>/(.*)./, :object=>'Object'
      capture_stdout {
        tab("obj = Object.new; def obj.class; end; obj.").should == []
      }.should == ''
    end

    # needed to ensure Bond works in irbrc
    it "doesn't evaluate irb binding on definition" do
      Object.expects(:const_defined?).never
      complete(:object=>"String")
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bond-0.4.2 test/object_mission_test.rb
bond-0.4.2-java test/object_mission_test.rb
bond-0.4.1 test/object_mission_test.rb
bond-0.4.0 test/object_mission_test.rb
bond-0.3.5 test/object_mission_test.rb
bond-0.3.4 test/object_mission_test.rb
bond-0.3.3 test/object_mission_test.rb
bond-0.3.2 test/object_mission_test.rb
bond-0.3.1 test/object_mission_test.rb
bond-0.3.0 test/object_mission_test.rb
bond-0.2.2 test/object_mission_test.rb
bond-0.2.1 test/object_mission_test.rb
bond-0.2.0 test/object_mission_test.rb