Sha256: 8a8c36a9b5df3359bff8630b068e610f8152f55f420a6e3a0a3d1ac45f6c9743

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe "Intercom::Message" do

  let (:user) {Intercom::User.new("email" => "jim@example.com", :user_id => "12345", :created_at => Time.now, :name => "Jim Bob")}
  let(:client) { Intercom::Client.new(token: 'token') }

  it 'creates an user message with symbol keys' do
    client.expects(:post).with('/messages', {'from' => { :type => 'user', :email => 'jim@example.com'}, 'body' => 'halp'}).returns(:status => 200)
    client.messages.create(:from => { :type => "user", :email => "jim@example.com" }, :body => "halp")
  end

  it "creates an user message with string keys" do
    client.expects(:post).with('/messages', {'from' => { 'type' => 'user', 'email' => 'jim@example.com'}, 'body' => 'halp'}).returns(:status => 200)
    client.messages.create('from' => { 'type' => "user", 'email' => "jim@example.com" }, 'body' => "halp")
  end

  it "creates a admin message" do
    client.expects(:post).with('/messages', {'from' => { 'type' => "admin", 'id' => "1234" }, 'to' => { 'type' => 'user', 'id' => '5678' }, 'body' => 'halp', 'message_type' => 'inapp'}).returns(:status => 200)
    client.messages.create('from' => { 'type' => "admin", 'id' => "1234" }, :to => { 'type' => 'user', 'id' => '5678' }, 'body' => "halp", 'message_type' => 'inapp')
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
intercom-4.2.1 spec/unit/intercom/message_spec.rb
intercom-4.2.0 spec/unit/intercom/message_spec.rb
intercom-4.1.3 spec/unit/intercom/message_spec.rb
intercom-4.1.2 spec/unit/intercom/message_spec.rb
intercom-4.1.1 spec/unit/intercom/message_spec.rb
intercom-4.1.0 spec/unit/intercom/message_spec.rb
intercom-4.0.1 spec/unit/intercom/message_spec.rb
intercom-4.0.0 spec/unit/intercom/message_spec.rb