require 'helper' describe Safubot::Bot do before(:all) do Safubot::Test.clean_environment end it 'should respond to basic queries' do $bot.once(:request) do |req| $bot.respond(req, "Pumpkin!") end $bot.answer("Pumpkin?").should == "Pumpkin!" end it 'should process requests with correct delegation' do req = Safubot::Test.request("Hello!") fired = false $bot.once(:request) do |request| request.should == req fired = true end $bot.process_request(req) do req.processed.should == true fired.should == true end end it 'should add a response to the queue' do req = Safubot::Test.request("Silly bot is silly.") $bot.once(:request) do |request| $bot.respond(req, "I am not silly! :<") end $bot.process_request(req) req.responses.count.should == 1 req.responses.first.request.should == req req.responses.first.text.should == "I am not silly! :<" end end