test/agent_test.rb in bond-0.1.0 vs test/agent_test.rb in bond-0.1.1

- old
+ new

@@ -42,23 +42,28 @@ Bond.complete(:on=>/bling/) {|e| raise "whoops" } capture_stderr { complete('bling') }.should =~ /bling.*whoops/m end end - # TODO - # test "default_mission set to a valid mission if irb doesn't exist" do - # old_default_action = Bond.agent.default_mission.action - # Bond.agent.instance_eval("@default_mission = @default_mission_action = nil") - # Object.expects(:const_defined?).with(:IRB).returns(false) - # Bond.agent.default_mission.is_a?(Bond::Mission).should == true - # Bond.agent.default_mission.action.respond_to?(:call).should == true - # Bond.agent.default_mission.instance_variable_set(:@action, old_default_action) - # end + context "spy" do + before(:all) { + Bond.reset; Bond.complete(:on=>/end$/) { [] }; Bond.complete(:method=>'the') { %w{spy who loved me} } + Bond.complete(:object=>"Symbol") + } - # test "binding set to toplevel binding if irb doesn't exist" do - # old_binding = Bond.agent.eval_binding - # Object.expects(:const_defined?).with(:IRB).returns(false) - # Bond.agent.instance_eval("@eval_binding = nil") - # Bond.agent.eval_binding.should == ::TOPLEVEL_BINDING - # Bond.agent.instance_variable_set(:@eval_binding, old_binding) - # end + test "detects basic mission" do + capture_stdout { Bond.spy('the end')}.should =~ /end/ + end + + test "detects object mission" do + capture_stdout { Bond.spy(':dude.i')}.should =~ /object.*Symbol.*dude\.id/m + end + + test "detects method mission" do + capture_stdout { Bond.spy('the ')}.should =~ /method.*the.*loved/m + end + + test "detects no mission" do + capture_stdout { Bond.spy('blah')}.should =~ /Doesn't match/ + end + end end