Skip to content

Commit

Permalink
More connection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cakejelly committed Jul 21, 2015
1 parent 6f68579 commit ad09367
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spec/cassettes/conversation.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions spec/layer/connection_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'spec_helper'

describe Layer::Api::Connection do

before do
@layer = Layer::Api::Client.new
@conn = @layer.connection
Expand Down Expand Up @@ -58,4 +59,36 @@
end
end
end

describe ".call" do
it "should run request & return response body" do
VCR.use_cassette('conversation') do
existing_conversation = @layer.create_conversation(conversation_params)
existing_id = @layer.get_stripped_id(existing_conversation["id"])

url = "#{@layer.base_url}/conversations/#{existing_id}"
body = @layer.call(:get, url, conversation_params)

# Compare body with expected values
expect(body["participants"]).to match_array(conversation_params[:participants])
expect(body["distinct"]).to eq(conversation_params[:distinct])
expect(body["metadata"].to_json).to eq(conversation_params[:metadata].to_json)
end
end

it "should run request & return nil if response has no body" do
VCR.use_cassette('conversation') do
existing_conversation = @layer.create_conversation(conversation_params)
existing_conversation_id = @layer.get_stripped_id(existing_conversation["id"])

operations = [
{operation: "add", property: "participants", value: "user1"},
{operation: "add", property: "participants", value: "user2"}
]

response = @layer.edit_conversation(existing_conversation_id, operations)
expect(response).to be(nil)
end
end
end
end

0 comments on commit ad09367

Please sign in to comment.