connect_client 0.2.2 → 0.3.1
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/.gitignore +39 -38
- data/Gemfile +2 -2
- data/LICENSE +22 -22
- data/README.md +45 -45
- data/Rakefile +21 -21
- data/connect_client.gemspec +24 -24
- data/data/cacert.pem +3988 -3988
- data/lib/connect_client.rb +48 -40
- data/lib/connect_client/client.rb +42 -42
- data/lib/connect_client/configuration.rb +11 -11
- data/lib/connect_client/event.rb +72 -72
- data/lib/connect_client/event_push_response.rb +48 -48
- data/lib/connect_client/http/deferred_http_response.rb +8 -8
- data/lib/connect_client/http/event_endpoint.rb +135 -131
- data/lib/connect_client/security/filtered_key_generation.rb +41 -0
- data/lib/connect_client/version.rb +1 -1
- data/spec/connect_client/client_spec.rb +68 -68
- data/spec/connect_client/configuration_spec.rb +54 -54
- data/spec/connect_client/event_push_response_spec.rb +149 -149
- data/spec/connect_client/event_spec.rb +93 -93
- data/spec/connect_client/http/http_event_endpoint_spec.rb +124 -124
- data/spec/connect_client/http/synchrony/{event_endpoint_spec.rb → http_event_endpoint_spec.rb} +59 -59
- data/spec/connect_client/security/filtered_key_generation_spec.rb +13 -0
- data/spec/connect_client_spec.rb +24 -24
- metadata +7 -4
@@ -1,55 +1,55 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'connect_client/configuration'
|
4
|
-
|
5
|
-
describe ConnectClient::Configuration do
|
6
|
-
|
7
|
-
it "should default the base_url to production" do
|
8
|
-
config = ConnectClient::Configuration.new
|
9
|
-
|
10
|
-
config.base_url.must_equal 'https://api.getconnect.io'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should default async to false" do
|
14
|
-
config = ConnectClient::Configuration.new
|
15
|
-
|
16
|
-
config.async.must_equal false
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should support setting the project id" do
|
20
|
-
config = ConnectClient::Configuration.new
|
21
|
-
id = 'id'
|
22
|
-
|
23
|
-
config.project_id = id
|
24
|
-
|
25
|
-
config.project_id.must_equal id
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should support setting the push key" do
|
29
|
-
config = ConnectClient::Configuration.new
|
30
|
-
key = 'key'
|
31
|
-
|
32
|
-
config.api_key = key
|
33
|
-
|
34
|
-
config.api_key.must_equal key
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should support setting whether requests are async" do
|
38
|
-
config = ConnectClient::Configuration.new
|
39
|
-
async = true
|
40
|
-
|
41
|
-
config.async = async
|
42
|
-
|
43
|
-
config.async.must_equal async
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should support setting the base url" do
|
47
|
-
config = ConnectClient::Configuration.new
|
48
|
-
url = 'url'
|
49
|
-
|
50
|
-
config.base_url = url
|
51
|
-
|
52
|
-
config.base_url.must_equal url
|
53
|
-
end
|
54
|
-
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'connect_client/configuration'
|
4
|
+
|
5
|
+
describe ConnectClient::Configuration do
|
6
|
+
|
7
|
+
it "should default the base_url to production" do
|
8
|
+
config = ConnectClient::Configuration.new
|
9
|
+
|
10
|
+
config.base_url.must_equal 'https://api.getconnect.io'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should default async to false" do
|
14
|
+
config = ConnectClient::Configuration.new
|
15
|
+
|
16
|
+
config.async.must_equal false
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should support setting the project id" do
|
20
|
+
config = ConnectClient::Configuration.new
|
21
|
+
id = 'id'
|
22
|
+
|
23
|
+
config.project_id = id
|
24
|
+
|
25
|
+
config.project_id.must_equal id
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should support setting the push key" do
|
29
|
+
config = ConnectClient::Configuration.new
|
30
|
+
key = 'key'
|
31
|
+
|
32
|
+
config.api_key = key
|
33
|
+
|
34
|
+
config.api_key.must_equal key
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should support setting whether requests are async" do
|
38
|
+
config = ConnectClient::Configuration.new
|
39
|
+
async = true
|
40
|
+
|
41
|
+
config.async = async
|
42
|
+
|
43
|
+
config.async.must_equal async
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should support setting the base url" do
|
47
|
+
config = ConnectClient::Configuration.new
|
48
|
+
url = 'url'
|
49
|
+
|
50
|
+
config.base_url = url
|
51
|
+
|
52
|
+
config.base_url.must_equal url
|
53
|
+
end
|
54
|
+
|
55
55
|
end
|
@@ -1,150 +1,150 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'connect_client/event'
|
4
|
-
require 'connect_client/event_push_response'
|
5
|
-
|
6
|
-
|
7
|
-
describe ConnectClient::EventPushResponse do
|
8
|
-
before do
|
9
|
-
@json_content_type = 'application/json; charset=utf-8'
|
10
|
-
@sample_event = ConnectClient::Event.new({name: 'test'})
|
11
|
-
@sample_event_data = @sample_event.data
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should be successful when status code is 201" do
|
15
|
-
|
16
|
-
body = ''
|
17
|
-
code = 201
|
18
|
-
|
19
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
20
|
-
|
21
|
-
event_response.success?.must_equal true
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should pass through string body if content type is not json" do
|
25
|
-
|
26
|
-
body = ''
|
27
|
-
code = 500
|
28
|
-
|
29
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
30
|
-
|
31
|
-
event_response.success?.must_equal false
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should not be successful when status code is 500" do
|
35
|
-
|
36
|
-
body = ''
|
37
|
-
code = 500
|
38
|
-
|
39
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
40
|
-
|
41
|
-
event_response.success?.must_equal false
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should not parse body that is not json content" do
|
45
|
-
|
46
|
-
content_type = 'text/html'
|
47
|
-
body = '<html><html>'
|
48
|
-
code = 500
|
49
|
-
|
50
|
-
event_response = ConnectClient::EventPushResponse.new code, content_type, body, @sample_event
|
51
|
-
|
52
|
-
event_response.data.must_equal body
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should set status code even if body is not json content" do
|
56
|
-
|
57
|
-
content_type = 'text/html'
|
58
|
-
body = '<html><html>'
|
59
|
-
code = 500
|
60
|
-
|
61
|
-
event_response = ConnectClient::EventPushResponse.new code, content_type, body, @sample_event
|
62
|
-
|
63
|
-
event_response.http_status_code.must_equal '500'
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
it "should pass through error message in data" do
|
68
|
-
|
69
|
-
body = '{ "errorMessage": "something went wrong" }'
|
70
|
-
code = 500
|
71
|
-
|
72
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
73
|
-
|
74
|
-
event_response.data[:errorMessage].must_equal 'something went wrong'
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should pass back event in response when successful" do
|
78
|
-
|
79
|
-
body = ''
|
80
|
-
code = 200
|
81
|
-
|
82
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
83
|
-
|
84
|
-
event_response.data[:event].must_be_same_as @sample_event_data
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should pass through original event with error" do
|
88
|
-
|
89
|
-
|
90
|
-
body = '{ "errorMessage": "something went wrong" }'
|
91
|
-
code = 500
|
92
|
-
|
93
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
94
|
-
|
95
|
-
event_response.data[:event].must_be_same_as @sample_event_data
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should pass through success status under collection name for batch" do
|
99
|
-
|
100
|
-
|
101
|
-
body = %@
|
102
|
-
{
|
103
|
-
"collectionName": [{
|
104
|
-
"success": true
|
105
|
-
}]
|
106
|
-
}
|
107
|
-
@
|
108
|
-
code = 200
|
109
|
-
|
110
|
-
events = { :collectionName => [@sample_event] }
|
111
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
112
|
-
|
113
|
-
event_response.data[:collectionName][0][:success].must_equal true
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should pass through duplicate status under collection name for batch" do
|
117
|
-
|
118
|
-
|
119
|
-
body = %@
|
120
|
-
{
|
121
|
-
"collectionName": [{
|
122
|
-
"duplicate": true
|
123
|
-
}]
|
124
|
-
}
|
125
|
-
@
|
126
|
-
code = 200
|
127
|
-
|
128
|
-
events = { :collectionName => [@sample_event] }
|
129
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
130
|
-
|
131
|
-
event_response.data[:collectionName][0][:duplicate].must_equal true
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should show event under collection name for batch" do
|
135
|
-
|
136
|
-
body = %@
|
137
|
-
{
|
138
|
-
"collectionName": [{
|
139
|
-
"success": true
|
140
|
-
}]
|
141
|
-
}
|
142
|
-
@
|
143
|
-
code = 200
|
144
|
-
|
145
|
-
events = { :collectionName => [@sample_event] }
|
146
|
-
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
147
|
-
|
148
|
-
event_response.data[:collectionName][0][:event].must_be_same_as @sample_event_data
|
149
|
-
end
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'connect_client/event'
|
4
|
+
require 'connect_client/event_push_response'
|
5
|
+
|
6
|
+
|
7
|
+
describe ConnectClient::EventPushResponse do
|
8
|
+
before do
|
9
|
+
@json_content_type = 'application/json; charset=utf-8'
|
10
|
+
@sample_event = ConnectClient::Event.new({name: 'test'})
|
11
|
+
@sample_event_data = @sample_event.data
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be successful when status code is 201" do
|
15
|
+
|
16
|
+
body = ''
|
17
|
+
code = 201
|
18
|
+
|
19
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
20
|
+
|
21
|
+
event_response.success?.must_equal true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should pass through string body if content type is not json" do
|
25
|
+
|
26
|
+
body = ''
|
27
|
+
code = 500
|
28
|
+
|
29
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
30
|
+
|
31
|
+
event_response.success?.must_equal false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not be successful when status code is 500" do
|
35
|
+
|
36
|
+
body = ''
|
37
|
+
code = 500
|
38
|
+
|
39
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
40
|
+
|
41
|
+
event_response.success?.must_equal false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not parse body that is not json content" do
|
45
|
+
|
46
|
+
content_type = 'text/html'
|
47
|
+
body = '<html><html>'
|
48
|
+
code = 500
|
49
|
+
|
50
|
+
event_response = ConnectClient::EventPushResponse.new code, content_type, body, @sample_event
|
51
|
+
|
52
|
+
event_response.data.must_equal body
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set status code even if body is not json content" do
|
56
|
+
|
57
|
+
content_type = 'text/html'
|
58
|
+
body = '<html><html>'
|
59
|
+
code = 500
|
60
|
+
|
61
|
+
event_response = ConnectClient::EventPushResponse.new code, content_type, body, @sample_event
|
62
|
+
|
63
|
+
event_response.http_status_code.must_equal '500'
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
it "should pass through error message in data" do
|
68
|
+
|
69
|
+
body = '{ "errorMessage": "something went wrong" }'
|
70
|
+
code = 500
|
71
|
+
|
72
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
73
|
+
|
74
|
+
event_response.data[:errorMessage].must_equal 'something went wrong'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should pass back event in response when successful" do
|
78
|
+
|
79
|
+
body = ''
|
80
|
+
code = 200
|
81
|
+
|
82
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
83
|
+
|
84
|
+
event_response.data[:event].must_be_same_as @sample_event_data
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should pass through original event with error" do
|
88
|
+
|
89
|
+
|
90
|
+
body = '{ "errorMessage": "something went wrong" }'
|
91
|
+
code = 500
|
92
|
+
|
93
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, @sample_event
|
94
|
+
|
95
|
+
event_response.data[:event].must_be_same_as @sample_event_data
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should pass through success status under collection name for batch" do
|
99
|
+
|
100
|
+
|
101
|
+
body = %@
|
102
|
+
{
|
103
|
+
"collectionName": [{
|
104
|
+
"success": true
|
105
|
+
}]
|
106
|
+
}
|
107
|
+
@
|
108
|
+
code = 200
|
109
|
+
|
110
|
+
events = { :collectionName => [@sample_event] }
|
111
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
112
|
+
|
113
|
+
event_response.data[:collectionName][0][:success].must_equal true
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should pass through duplicate status under collection name for batch" do
|
117
|
+
|
118
|
+
|
119
|
+
body = %@
|
120
|
+
{
|
121
|
+
"collectionName": [{
|
122
|
+
"duplicate": true
|
123
|
+
}]
|
124
|
+
}
|
125
|
+
@
|
126
|
+
code = 200
|
127
|
+
|
128
|
+
events = { :collectionName => [@sample_event] }
|
129
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
130
|
+
|
131
|
+
event_response.data[:collectionName][0][:duplicate].must_equal true
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should show event under collection name for batch" do
|
135
|
+
|
136
|
+
body = %@
|
137
|
+
{
|
138
|
+
"collectionName": [{
|
139
|
+
"success": true
|
140
|
+
}]
|
141
|
+
}
|
142
|
+
@
|
143
|
+
code = 200
|
144
|
+
|
145
|
+
events = { :collectionName => [@sample_event] }
|
146
|
+
event_response = ConnectClient::EventPushResponse.new code, @json_content_type, body, events
|
147
|
+
|
148
|
+
event_response.data[:collectionName][0][:event].must_be_same_as @sample_event_data
|
149
|
+
end
|
150
150
|
end
|
@@ -1,94 +1,94 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'connect_client/event'
|
4
|
-
|
5
|
-
describe ConnectClient::Event do
|
6
|
-
it "should throw a validation exception if a property starts with tp_" do
|
7
|
-
connect_event = proc { ConnectClient::Event.new({tp_foo: 'bar'}) }.must_raise ConnectClient::EventDataValidationError
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should supply an id if none present" do
|
11
|
-
connect_event = ConnectClient::Event.new({foo: 'bar'})
|
12
|
-
uuid_regex = /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/
|
13
|
-
|
14
|
-
connect_event.data[:id].must_match uuid_regex
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should pass through id supplied" do
|
18
|
-
connect_event = ConnectClient::Event.new({id: :bar})
|
19
|
-
|
20
|
-
connect_event.data[:id].must_equal :bar
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should supply timestamp if none present" do
|
24
|
-
iso_date = '2015-07-01T04:07:57Z'
|
25
|
-
a_time = Time.parse(iso_date);
|
26
|
-
|
27
|
-
Time.stub :now, a_time do
|
28
|
-
connect_event = ConnectClient::Event.new({foo: 'bar'})
|
29
|
-
connect_event.data[:timestamp].must_equal iso_date
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should turn timestamp into iso string" do
|
34
|
-
iso_date = '2015-07-01T04:07:57Z'
|
35
|
-
a_time = Time.parse(iso_date);
|
36
|
-
|
37
|
-
connect_event = ConnectClient::Event.new({foo: 'bar', timestamp: a_time})
|
38
|
-
connect_event.data[:timestamp].must_equal iso_date
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should pass through timestamp string if supplied" do
|
42
|
-
iso_date = '2015-07-01T04:07:57Z'
|
43
|
-
|
44
|
-
connect_event = ConnectClient::Event.new({foo: 'bar', timestamp: iso_date})
|
45
|
-
connect_event.data[:timestamp].must_equal iso_date
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should turn Time into iso8601" do
|
49
|
-
iso_date = '2015-07-01T04:07:57Z'
|
50
|
-
some_time = Time.parse('2015-07-01T05:07:57+01:00')
|
51
|
-
|
52
|
-
nested_hash_values = {
|
53
|
-
this: {
|
54
|
-
is: {
|
55
|
-
nested: [[some_time]]
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
connect_event = ConnectClient::Event.new(nested_hash_values)
|
61
|
-
connect_event.data[:this][:is][:nested][0][0].must_equal iso_date
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should turn DateTime into iso8601" do
|
65
|
-
iso_date = '2015-07-01T04:07:57Z'
|
66
|
-
some_date_time = DateTime.parse('2015-07-01T05:07:57+01:00')
|
67
|
-
|
68
|
-
nested_hash_values = {
|
69
|
-
this: {
|
70
|
-
is: {
|
71
|
-
nested: [[some_date_time]]
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
connect_event = ConnectClient::Event.new(nested_hash_values)
|
77
|
-
connect_event.data[:this][:is][:nested][0][0].must_equal iso_date
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should turn Date into iso8601" do
|
81
|
-
some_date = Date.parse('2015-07-01')
|
82
|
-
|
83
|
-
nested_hash_values = {
|
84
|
-
this: {
|
85
|
-
is: {
|
86
|
-
nested: [[some_date]]
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
connect_event = ConnectClient::Event.new(nested_hash_values)
|
92
|
-
connect_event.data[:this][:is][:nested][0][0].must_equal some_date.to_time.utc.iso8601
|
93
|
-
end
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'connect_client/event'
|
4
|
+
|
5
|
+
describe ConnectClient::Event do
|
6
|
+
it "should throw a validation exception if a property starts with tp_" do
|
7
|
+
connect_event = proc { ConnectClient::Event.new({tp_foo: 'bar'}) }.must_raise ConnectClient::EventDataValidationError
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should supply an id if none present" do
|
11
|
+
connect_event = ConnectClient::Event.new({foo: 'bar'})
|
12
|
+
uuid_regex = /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/
|
13
|
+
|
14
|
+
connect_event.data[:id].must_match uuid_regex
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should pass through id supplied" do
|
18
|
+
connect_event = ConnectClient::Event.new({id: :bar})
|
19
|
+
|
20
|
+
connect_event.data[:id].must_equal :bar
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should supply timestamp if none present" do
|
24
|
+
iso_date = '2015-07-01T04:07:57Z'
|
25
|
+
a_time = Time.parse(iso_date);
|
26
|
+
|
27
|
+
Time.stub :now, a_time do
|
28
|
+
connect_event = ConnectClient::Event.new({foo: 'bar'})
|
29
|
+
connect_event.data[:timestamp].must_equal iso_date
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should turn timestamp into iso string" do
|
34
|
+
iso_date = '2015-07-01T04:07:57Z'
|
35
|
+
a_time = Time.parse(iso_date);
|
36
|
+
|
37
|
+
connect_event = ConnectClient::Event.new({foo: 'bar', timestamp: a_time})
|
38
|
+
connect_event.data[:timestamp].must_equal iso_date
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should pass through timestamp string if supplied" do
|
42
|
+
iso_date = '2015-07-01T04:07:57Z'
|
43
|
+
|
44
|
+
connect_event = ConnectClient::Event.new({foo: 'bar', timestamp: iso_date})
|
45
|
+
connect_event.data[:timestamp].must_equal iso_date
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should turn Time into iso8601" do
|
49
|
+
iso_date = '2015-07-01T04:07:57Z'
|
50
|
+
some_time = Time.parse('2015-07-01T05:07:57+01:00')
|
51
|
+
|
52
|
+
nested_hash_values = {
|
53
|
+
this: {
|
54
|
+
is: {
|
55
|
+
nested: [[some_time]]
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
connect_event = ConnectClient::Event.new(nested_hash_values)
|
61
|
+
connect_event.data[:this][:is][:nested][0][0].must_equal iso_date
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should turn DateTime into iso8601" do
|
65
|
+
iso_date = '2015-07-01T04:07:57Z'
|
66
|
+
some_date_time = DateTime.parse('2015-07-01T05:07:57+01:00')
|
67
|
+
|
68
|
+
nested_hash_values = {
|
69
|
+
this: {
|
70
|
+
is: {
|
71
|
+
nested: [[some_date_time]]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
connect_event = ConnectClient::Event.new(nested_hash_values)
|
77
|
+
connect_event.data[:this][:is][:nested][0][0].must_equal iso_date
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should turn Date into iso8601" do
|
81
|
+
some_date = Date.parse('2015-07-01')
|
82
|
+
|
83
|
+
nested_hash_values = {
|
84
|
+
this: {
|
85
|
+
is: {
|
86
|
+
nested: [[some_date]]
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
connect_event = ConnectClient::Event.new(nested_hash_values)
|
92
|
+
connect_event.data[:this][:is][:nested][0][0].must_equal some_date.to_time.utc.iso8601
|
93
|
+
end
|
94
94
|
end
|