Sha256: 7607e5be017f0dfd94e7616d389ef18b538a9b6aaf759cc569391c5686f9afb5

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require_relative "../../../helper"
require_relative "../../../../lib/fabriq/skype/message"

describe Fabriq::Skype::Message do

  before do
    @room = mock('Room')
    @message = Fabriq::Skype::Message.new(@room, "Lorem Ipsum")
    @message.config = @config = mock('Config')
  end

  describe "#private_session?" do
    it "returns false" do
      @room.stubs(:private_session?).returns(false)
      @message.private_session?.must_equal(false)
    end

    it "returns true if the room is a private session" do
      @room.stubs(:private_session?).returns(true)
      @message.private_session?.must_equal(true)
    end
  end

  describe '#direct?' do
    it "returns false if no Config#skype_name is set" do
      @config.stubs(:skype_name).returns(nil)
      @message.direct?.must_equal(false)
    end

    it "returns false if beginning of message does not contain the configured skype name" do
      @message.body = "@peter Hallo"
      @config.stubs(:skype_name).returns("Maja")
      @message.direct?.must_equal(false)
    end

    it "returns true if the beginning of the message contains the configured skype name" do
      @message.body = "@Maja Hallo"
      @config.stubs(:skype_name).returns("Maja")
      @message.direct?.must_equal(true)
    end

    it "returns true if the beginning of the message contains the configured skype name, ignoring case" do
      @message.body = "@Maja Hallo"
      @config.stubs(:skype_name).returns("maja")
      @message.direct?.must_equal(true)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fabriq-0.1.0 spec/lib/fabriq/skype/message_spec.rb