connect_client 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683a804acba4b229a9419fe6edab311a94bc636b
4
- data.tar.gz: 22e11a9ec22e2d8ff27d98835fc986e6b1d9698b
3
+ metadata.gz: b75b4c84d06d88fa34c79d166ddeb39134a5ae37
4
+ data.tar.gz: cab664f0cd325dd5322277ec537cae5c691006d3
5
5
  SHA512:
6
- metadata.gz: 73958e1001bdc8d10e0524d3c7af743542c5e63a321543df94be34b10d9d7e433cdf6afcc99170ddee5920013c1fb525f0344e0573b887cc1bd7b7a0d9a09090
7
- data.tar.gz: 5ac1394f77793c2ca194afbf532f91f93240e4aa5437427e3495591ffadd0af4df1ee44906b0a1b6e1453a02de11df733d259bad5d945f8b447f233ef2f18af9
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
@@ -1,3 +1,3 @@
1
1
  module ConnectClient
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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 multiple events to a collection" do
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").
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connect_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Connect