Skip to content

Commit ad09367

Browse files
committed
More connection tests
1 parent 6f68579 commit ad09367

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

spec/cassettes/conversation.yml

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/layer/connection_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'spec_helper'
22

33
describe Layer::Api::Connection do
4+
45
before do
56
@layer = Layer::Api::Client.new
67
@conn = @layer.connection
@@ -58,4 +59,36 @@
5859
end
5960
end
6061
end
62+
63+
describe ".call" do
64+
it "should run request & return response body" do
65+
VCR.use_cassette('conversation') do
66+
existing_conversation = @layer.create_conversation(conversation_params)
67+
existing_id = @layer.get_stripped_id(existing_conversation["id"])
68+
69+
url = "#{@layer.base_url}/conversations/#{existing_id}"
70+
body = @layer.call(:get, url, conversation_params)
71+
72+
# Compare body with expected values
73+
expect(body["participants"]).to match_array(conversation_params[:participants])
74+
expect(body["distinct"]).to eq(conversation_params[:distinct])
75+
expect(body["metadata"].to_json).to eq(conversation_params[:metadata].to_json)
76+
end
77+
end
78+
79+
it "should run request & return nil if response has no body" do
80+
VCR.use_cassette('conversation') do
81+
existing_conversation = @layer.create_conversation(conversation_params)
82+
existing_conversation_id = @layer.get_stripped_id(existing_conversation["id"])
83+
84+
operations = [
85+
{operation: "add", property: "participants", value: "user1"},
86+
{operation: "add", property: "participants", value: "user2"}
87+
]
88+
89+
response = @layer.edit_conversation(existing_conversation_id, operations)
90+
expect(response).to be(nil)
91+
end
92+
end
93+
end
6194
end

0 commit comments

Comments
 (0)