Sha256: 813b01ddb95d68e50aa07a3433fb500e4e174107843be544ba45a408e72a7ceb

Contents?: true

Size: 1.91 KB

Versions: 6

Compression:

Stored size: 1.91 KB

Contents

require "spec_helper"

RSpec.describe Ribose::Message do
  describe ".all" do
    it "retrieves all conversation messages" do
      space_id = 123_456
      conversation_id = 456_789
      stub_ribose_message_list(space_id, conversation_id)

      messages = Ribose::Message.all(
        space_id: space_id, conversation_id: conversation_id,
      )

      expect(messages.first.id).not_to be_nil
      expect(messages.first.user.name).to eq("John Doe")
      expect(messages.first.contents).to eq("Welcome to Ribose Space")
    end
  end

  describe ".create" do
    it "creates a new message into a conversation" do
      space_id = 123_456

      stub_ribose_message_create(space_id, message: message_attrs)
      message = Ribose::Message.create(message_attrs.merge(space_id: space_id))

      expect(message.id).not_to be_nil
      expect(message.user.name).to eq("John Doe")
      expect(message.contents).to eq("Welcome to Ribose")
    end
  end

  describe ".update" do
    it "updates an existing conversation message" do
      space_id = 123_456
      message_id = 789_012_345

      stub_ribose_message_update(space_id, message_id, message: message_attrs)
      message = Ribose::Message.update(
        message_attrs.merge(space_id: space_id, message_id: message_id),
      )

      expect(message.user.name).to eq("John Doe")
      expect(message.contents).to eq("Welcome to Ribose")
    end
  end

  describe ".remove" do
    it "remvoes a message from the conversation" do
      space_id = 123_456
      message_id = 789_012_345
      conversation_id = 9282737373

      stub_ribose_message_remove(space_id, message_id, conversation_id)

      expect do
        Ribose::Message.remove(
          space_id: space_id,
          message_id: message_id,
          conversation_id: conversation_id,
        )
      end.not_to raise_error
    end
  end

  def message_attrs
    { contents: "Welcome to Ribose", conversation_id: "456789" }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ribose-0.4.1 spec/ribose/message_spec.rb
ribose-0.4.0 spec/ribose/message_spec.rb
ribose-0.3.2 spec/ribose/message_spec.rb
ribose-0.3.1 spec/ribose/message_spec.rb
ribose-0.3.0 spec/ribose/message_spec.rb
ribose-0.2.0 spec/ribose/message_spec.rb