Sha256: c9f17abb0c1f0173738fccf8949ff6e69895949f5b7c7202e0187892325faeb3
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
require_relative "../../../helper" require_relative "../../../../lib/fabriq/skype/message" require_relative "../../../../lib/fabriq/skype/room" describe Fabriq::Skype::Room do before do @adapter = mock('Adapter') @members = [] @room = Fabriq::Skype::Room.new(@adapter, "ab-99", @members, "raw") end describe '#private_session?' do it "returns true if 2 members are in the room" do @room.members = ["a", "b"] @room.private_session?.must_equal(true) end it "returns false if more than 2 members are in the room" do @room.members = ["a", "b", "c"] @room.private_session?.must_equal(false) end end describe '#send_message' do before do @adapter.stubs(:enqueue_outgoing_message) end it "builds a message from the passed string" do opts = {} @room.expects(:build_message_from_string).with("test", opts) @room.send_message("test", opts) end it "enqueues the message in the outgoing channel" do message = mock('Message') @room.stubs(:build_message_from_string).returns(message) @adapter.expects(:enqueue_outgoing_message).with(message) @room.send_message("test") end end describe '#build_message_from_string' do it "creates a message object" do @room.build_message_from_string("text").must_be_kind_of(Fabriq::Skype::Message) end it "assigns itself as room to the new message" do @room.build_message_from_string("text").room.must_equal(@room) end it "assigns the passed body to the new message" do @room.build_message_from_string("text").body.must_equal("text") end it "adds @name to the message if opts[to] is passed" do @room.build_message_from_string("text", to: "treas").body.must_match(/@treas:/) end it "does not add @name if its a private session" do @room.stubs(:private_session?).returns(true) @room.build_message_from_string("text", to: "treas").body.wont_match(/@treas:/) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fabriq-0.1.0 | spec/lib/fabriq/skype/room_spec.rb |