Sha256: ac286f5dbea5c43cc2ec01458f9a2581b181fcc210b560b081b53c6229facfe4

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

include Botfly
describe CommonResponderMethods do
  let(:bot) { stub("Bot", :client => stub("client"))}
  let(:responder) do
    class Responder; include CommonResponderMethods; end;
    Responder.new(bot)
  end

  describe "#remove" do
    # Don't test all of #remove_responder, that's tested elsewhere ;)
    it "should ask class's bot to remove responder of given id" do
      bot.should_receive(:remove_responder).with(:foo)
      responder.remove(:foo)
    end
  end

  describe "#send" do
    before(:each) do
      responder.bot.stub_chain(:jid,:domain => 'foo.com')
    end
    after(:each) { responder.tell('foo@bar.baz/home', "message") }
    subject { responder }
    
    it "should pass the message along to the bot's jabber client" do
      responder.client.should_receive(:send).with(an_instance_of(Jabber::Message))
    end

    it "should set the nickname and body appropriately in the message" do
      responder.client.should_receive(:send) do |msg|
        msg.to.to_s.should == 'foo@bar.baz/home'
        msg.body.should == 'message'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
botfly-0.3.6 spec/botfly/responder/common_responder_methods_spec.rb
botfly-0.3.5 spec/botfly/responder/common_responder_methods_spec.rb
botfly-0.3.4 spec/botfly/responder/common_responder_methods_spec.rb