Sha256: c8850cb20b595b09baf117d0df9922f140f5c3299006519341319a25e59f4339

Contents?: true

Size: 1.28 KB

Versions: 53

Compression:

Stored size: 1.28 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(app_id: 'app_id',  api_key: 'api_key') }

  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

53 entries across 53 versions & 1 rubygems

Version Path
intercom-3.5.24 spec/unit/intercom/message_spec.rb
intercom-3.5.23 spec/unit/intercom/message_spec.rb
intercom-3.5.22 spec/unit/intercom/message_spec.rb
intercom-3.5.21 spec/unit/intercom/message_spec.rb
intercom-3.5.20 spec/unit/intercom/message_spec.rb
intercom-3.5.19 spec/unit/intercom/message_spec.rb
intercom-3.5.17 spec/unit/intercom/message_spec.rb
intercom-3.5.16 spec/unit/intercom/message_spec.rb
intercom-3.5.15 spec/unit/intercom/message_spec.rb
intercom-3.5.14 spec/unit/intercom/message_spec.rb
intercom-3.5.12 spec/unit/intercom/message_spec.rb
intercom-3.5.11 spec/unit/intercom/message_spec.rb
intercom-3.5.10 spec/unit/intercom/message_spec.rb
intercom-3.5.9 spec/unit/intercom/message_spec.rb
intercom-3.5.8 spec/unit/intercom/message_spec.rb
intercom-3.5.7 spec/unit/intercom/message_spec.rb
intercom-3.5.6 spec/unit/intercom/message_spec.rb
intercom-3.5.5 spec/unit/intercom/message_spec.rb
intercom-3.5.4 spec/unit/intercom/message_spec.rb
intercom-3.5.3 spec/unit/intercom/message_spec.rb