test/object_mission_test.rb in bond-0.1.4 vs test/object_mission_test.rb in bond-0.2.0

- old
+ new

@@ -1,63 +1,59 @@ require File.join(File.dirname(__FILE__), 'test_helper') -class Bond::ObjectMissionTest < Test::Unit::TestCase - before(:all) {|e| Bond.debrief(:readline_plugin=>valid_readline_plugin) } - before(:each) {|e| Bond.agent.reset } - context "object mission" do - test "with default action completes" do +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}} - tabtab("'man'.u").should == [".upcase!", ".unpack", ".untaint", ".upcase", ".upto"] + tab("'man'.up").sort.should == [".upcase", ".upcase!", ".upto"] end - test "with regex condition completes" do - complete(:object=>/Str/) {|e| e.object.class.superclass.instance_methods(true) } + it "with regex condition completes" do + complete(:object=>'Str.*') {|e| e.object.class.superclass.instance_methods(true) } complete(:on=>/man/) { %w{upper upster upful}} - tabtab("'man'.u").should == [".untaint"] + tab("'man'.unta").should == [".untaint"] end - test "with explicit action completes" do + it "with explicit action completes" do complete(:object=>"String") {|e| e.object.class.superclass.instance_methods(true) } complete(:on=>/man/) { %w{upper upster upful}} - tabtab("'man'.u").should == [".untaint"] + tab("'man'.unta").should == [".untaint"] end - test "completes without including word break characters" do + it "completes without including word break characters" do complete(:object=>"Hash") - matches = tabtab("{}.f") - assert matches.size > 0 + matches = tab("{}.f") + matches.size.should.be > 0 matches.all? {|e| !e.include?('{')}.should == true end - test "completes nil, false and range objects" do + it "completes with additional text after completion point" do complete(:object=>"Object") - assert tabtab("nil.f").size > 0 - assert tabtab("false.f").size > 0 - assert tabtab("(1..10).f").size > 0 + tab(':man.f blah', ':man.f').include?(':man.freeze').should == true end - test "completes hashes and arrays with spaces" do - complete(:object=>"Object") - assert tabtab("[1, 2].f").size > 0 - assert tabtab("{:a =>1}.f").size > 0 + it "doesn't evaluate anything before the completion object" do + complete(:object=>'Object') + tab('raise :man.i').size.should > 0 end - test "ignores invalid invalid ruby" do + it "ignores invalid ruby" do complete(:object=>"String") - tabtab("blah.upt").should == [] + 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 - test "doesn't evaluate irb binding on definition" do + it "doesn't evaluate irb binding on definition" do Object.expects(:const_defined?).never complete(:object=>"String") - end - - test "sets binding to toplevel binding when not in irb" do - Object.expects(:const_defined?).with(:IRB).returns(false) - mission = Bond::Mission.create(:object=>'Symbol') - mission.class.expects(:eval).with(anything, ::TOPLEVEL_BINDING) - mission.matches?(':ok.') end end end \ No newline at end of file