connect_client 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/connect_client/client.rb +1 -1
- data/lib/connect_client/version.rb +1 -1
- data/spec/connect_client/client_spec.rb +23 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b75b4c84d06d88fa34c79d166ddeb39134a5ae37
|
4
|
+
data.tar.gz: cab664f0cd325dd5322277ec537cae5c691006d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a24aceb48d805a4009c14765f163f87e4239be0a59c9ed1a0975d44283567c1b81cb96d22fba53540c9b46437f6ad09232ced50d2638112ed6a09a39387664
|
7
|
+
data.tar.gz: 7c5cf84be93ba408c6240fb92cfd943ec54585704b324c6e43a574c60484e3f6e9b6c1c29a0fafc6f31e980f666cf623bcffed65d7f3e539b4fc5014543fd6bb
|
@@ -10,7 +10,7 @@ module ConnectClient
|
|
10
10
|
|
11
11
|
def push(collection_name_or_batches, event_or_events = nil)
|
12
12
|
has_multiple_events = event_or_events.is_a?(Array)
|
13
|
-
has_collection_name = collection_name_or_batches.is_a?(String)
|
13
|
+
has_collection_name = collection_name_or_batches.is_a?(String) || collection_name_or_batches.is_a?(Symbol)
|
14
14
|
is_batch = !has_collection_name || has_multiple_events
|
15
15
|
|
16
16
|
if is_batch
|
@@ -14,9 +14,10 @@ describe ConnectClient::Client do
|
|
14
14
|
@sample_events = [@sample_event]
|
15
15
|
@sample_events_reponse = '{"sample": [{"success": true}]}'
|
16
16
|
@sample_collection = 'sample'
|
17
|
+
@sample_collection_sym = :sample
|
17
18
|
end
|
18
19
|
|
19
|
-
it "should get a push response back when pushing a single event to a collection" do
|
20
|
+
it "should get a push response back when pushing a single event to a collection passed by string" do
|
20
21
|
stub_request(:post, "https://api.getconnect.io/events/#{@sample_collection}").
|
21
22
|
with(:body => @sample_event).
|
22
23
|
to_return(:status => 200, :body => "", :headers => { 'Content-Type'=>'application/json' })
|
@@ -26,7 +27,17 @@ describe ConnectClient::Client do
|
|
26
27
|
response.must_be_instance_of ConnectClient::EventPushResponse
|
27
28
|
end
|
28
29
|
|
29
|
-
it "should get a push response back when pushing
|
30
|
+
it "should get a push response back when pushing a single event to a collection passed by symbol" do
|
31
|
+
stub_request(:post, "https://api.getconnect.io/events/#{@sample_collection}").
|
32
|
+
with(:body => @sample_event).
|
33
|
+
to_return(:status => 200, :body => "", :headers => { 'Content-Type'=>'application/json' })
|
34
|
+
|
35
|
+
response = @client.push @sample_collection_sym, @sample_event
|
36
|
+
|
37
|
+
response.must_be_instance_of ConnectClient::EventPushResponse
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should get a push response back when pushing multiple events to a collection passed by string" do
|
30
41
|
stub_request(:post, "https://api.getconnect.io/events").
|
31
42
|
with(:body => { @sample_collection.to_sym => @sample_events }).
|
32
43
|
to_return(:status => 200, :body => @sample_events_reponse, :headers => { 'Content-Type'=>'application/json' })
|
@@ -36,6 +47,16 @@ describe ConnectClient::Client do
|
|
36
47
|
response.must_be_instance_of ConnectClient::EventPushResponse
|
37
48
|
end
|
38
49
|
|
50
|
+
it "should get a push response back when pushing multiple events to a collection passed by symbol" do
|
51
|
+
stub_request(:post, "https://api.getconnect.io/events").
|
52
|
+
with(:body => { @sample_collection_sym => @sample_events }).
|
53
|
+
to_return(:status => 200, :body => @sample_events_reponse, :headers => { 'Content-Type'=>'application/json' })
|
54
|
+
|
55
|
+
response = @client.push @sample_collection_sym, @sample_events
|
56
|
+
|
57
|
+
response.must_be_instance_of ConnectClient::EventPushResponse
|
58
|
+
end
|
59
|
+
|
39
60
|
it "should get a push response back when pushing batches" do
|
40
61
|
batch = { @sample_collection.to_sym => @sample_events }
|
41
62
|
stub_request(:post, "https://api.getconnect.io/events").
|