keen 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MmM2M2JiNDY0NWU3NDBkYTI4N2QzNDEwNzYwNjkyMmZkYzI5NjQ2Yw==
5
- data.tar.gz: !binary |-
6
- MGY5ZTNiZWUwNGY4ZTE2Y2JmZTdiNGU4MjdiMDBlOTU5NmI2NWFiYw==
2
+ SHA1:
3
+ metadata.gz: 38dbcdb5882d0ecaca4d8a069ba569b12ed28fc7
4
+ data.tar.gz: 9a5278be0634db7ca4658b9dff70c46b0750e77e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Y2UwMzI3NjRjMDgyMWJlNjI2M2JiMTZkOWQyM2RjYmEyYTAzYjkzMDk2N2Q2
10
- ZWJlZTc0NTA1YzUzNGIwOTg0MWQ5NGMwNWQyMTQxODQxZDM4OTRhNWIyN2I4
11
- MDBmNWRhYWMzODE3ZGU2NDQxMDY3Mjk1MTJmZTEyNTg1ZmNlNGM=
12
- data.tar.gz: !binary |-
13
- M2I3MDNlZTQzYTY0OWJiMjAzZTA4M2FmMjUxOTBjNmZiYzY2YWM3NjczYzE1
14
- MWI5NDlmMzA2ZDNhNTA3NWU1NDIxOGRiM2NhY2Y4NGY3NWZjZWY0MDMwZTc5
15
- NjExYzkyZmZjYzI3YWFjMmU2MWFmMTc4OTYwMjFhYTI3YzMxNjE=
6
+ metadata.gz: ce6065efb92a0ec0aa8073a43ee0f7a3df9da5dd412ed967b84ae88af4e51c3ca8043cfe10f85635e5aa6978fba720ff6d11a8deabd8a3547d3529f3358ea791
7
+ data.tar.gz: d1a51bd9f953b0d401654b28e1ccc08623cba520a978db467d0ab146d30c15d0dae221ac41e57529bbb6e987b0376a067fe9cb201fee51f3b6d834a45fe20363
data/README.md CHANGED
@@ -412,6 +412,9 @@ If you want some bot protection, check out the [Voight-Kampff](https://github.co
412
412
 
413
413
  ### Changelog
414
414
 
415
+ ##### 0.9.9
416
+ + Added the ability to send additional optional headers.
417
+
415
418
  ##### 0.9.7
416
419
  + Added a new header `Keen-Sdk` that sends the SDK version information on all requests.
417
420
 
@@ -10,7 +10,7 @@ module Keen
10
10
  #
11
11
  # @return the JSON response from the API
12
12
  def add_event(event_collection, properties, options={})
13
- self.publish(event_collection, properties, options)
13
+ self.publish(event_collection, properties)
14
14
  end
15
15
 
16
16
  # Publishes a synchronous event
@@ -222,10 +222,10 @@ module Keen
222
222
  def query(analysis_type, event_collection, params={}, options={})
223
223
  response =
224
224
  if options[:method] == :post
225
- post_query(analysis_type, event_collection, params)
225
+ post_query(analysis_type, event_collection, params, options)
226
226
  else
227
227
  url = _query_url(analysis_type, event_collection, params, options)
228
- get_response(url)
228
+ get_response(url, options)
229
229
  end
230
230
 
231
231
  response_body = response.body.chomp
@@ -236,7 +236,7 @@ module Keen
236
236
 
237
237
  private
238
238
 
239
- def post_query(analysis_type, event_collection, params={})
239
+ def post_query(analysis_type, event_collection, params={}, options={})
240
240
  ensure_project_id!
241
241
  ensure_read_key!
242
242
 
@@ -244,7 +244,7 @@ module Keen
244
244
  query_params[:event_collection] = event_collection.to_s if event_collection
245
245
  Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout).post(
246
246
  :path => api_query_resource_path(analysis_type),
247
- :headers => api_headers(self.read_key, "sync"),
247
+ :headers => request_headers(options),
248
248
  :body => MultiJson.encode(query_params)
249
249
  )
250
250
  rescue Exception => http_error
@@ -260,11 +260,11 @@ module Keen
260
260
  "#{self.api_url}#{api_query_resource_path(analysis_type)}?#{preprocess_params(query_params)}"
261
261
  end
262
262
 
263
- def get_response(url)
263
+ def get_response(url, options={})
264
264
  uri = URI.parse(url)
265
265
  Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout).get(
266
266
  :path => "#{uri.path}?#{uri.query}",
267
- :headers => api_headers(self.read_key, "sync")
267
+ :headers => request_headers(options)
268
268
  )
269
269
  rescue Exception => http_error
270
270
  raise HttpError.new("Couldn't perform #{@analysis_type} on Keen IO: #{http_error.message}", http_error)
@@ -273,6 +273,11 @@ module Keen
273
273
  def api_query_resource_path(analysis_type)
274
274
  "/#{self.api_version}/projects/#{self.project_id}/queries/#{analysis_type}"
275
275
  end
276
+
277
+ def request_headers(options={})
278
+ base_headers = api_headers(self.read_key, "sync")
279
+ options.has_key?(:headers) ? base_headers.merge(options[:headers]) : base_headers
280
+ end
276
281
  end
277
282
  end
278
283
  end
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
@@ -20,7 +20,7 @@ describe Keen::Client do
20
20
  it 'should not require filters' do
21
21
  url = delete_url(event_collection)
22
22
  stub_keen_delete(url, 204)
23
- client.delete(event_collection).should == true
23
+ expect(client.delete(event_collection)).to be true
24
24
  expect_keen_delete(url, "sync", master_key)
25
25
  end
26
26
 
@@ -42,7 +42,7 @@ describe Keen::Client do
42
42
 
43
43
  it "should fetch the project's event resource" do
44
44
  stub_keen_get(events_url, 200, [{ "a" => 1 }, { "b" => 2 }] )
45
- client.event_collections.should == [{ "a" => 1 }, { "b" => 2 }]
45
+ expect(client.event_collections).to match_array([{ "a" => 1 }, { "b" => 2 }])
46
46
  expect_keen_get(events_url, "sync", master_key)
47
47
  end
48
48
  end
@@ -53,7 +53,7 @@ describe Keen::Client do
53
53
 
54
54
  it "should fetch the project's named event resource" do
55
55
  stub_keen_get(events_url, 200, [{ "b" => 2 }] )
56
- client.event_collection(event_collection).should == [{ "b" => 2 }]
56
+ expect(client.event_collection(event_collection)).to match_array([{ "b" => 2 }])
57
57
  expect_keen_get(events_url, "sync", master_key)
58
58
  end
59
59
  end
@@ -63,7 +63,7 @@ describe Keen::Client do
63
63
 
64
64
  it "should fetch the project resource" do
65
65
  stub_keen_get(project_url, 200, [{ "a" => 1 }, { "b" => 2 }] )
66
- client.project_info.should == [{ "a" => 1 }, { "b" => 2 }]
66
+ expect(client.project_info).to match_array([{ "a" => 1 }, { "b" => 2 }])
67
67
  expect_keen_get(project_url, "sync", master_key)
68
68
  end
69
69
  end
@@ -21,7 +21,7 @@ describe Keen::Client::PublishingMethods do
21
21
  it "should return the proper response" do
22
22
  api_response = { "created" => true }
23
23
  stub_keen_post(api_event_collection_resource_url(api_url, collection), 201, api_response)
24
- client.publish(collection, event_properties).should == api_response
24
+ expect(client.publish(collection, event_properties)).to eq(api_response)
25
25
  end
26
26
 
27
27
  it "should raise an argument error if no event collection is specified" do
@@ -51,9 +51,9 @@ describe Keen::Client::PublishingMethods do
51
51
  e = exception
52
52
  end
53
53
 
54
- e.class.should == Keen::HttpError
55
- e.original_error.should be_kind_of(Timeout::Error)
56
- e.message.should == "Keen IO Exception: HTTP publish failure: execution expired"
54
+ expect(e.class).to eq(Keen::HttpError)
55
+ expect(e.original_error).to be_kind_of(Timeout::Error)
56
+ expect(e.message).to eq("Keen IO Exception: HTTP publish failure: execution expired")
57
57
  end
58
58
 
59
59
  it "should raise an exception if client has no project_id" do
@@ -84,7 +84,7 @@ describe Keen::Client::PublishingMethods do
84
84
  it "should return the proper response" do
85
85
  api_response = { "created" => true }
86
86
  stub_keen_post(api_event_collection_resource_url(api_url, collection), 201, api_response)
87
- client.publish(collection, event_properties).should == api_response
87
+ expect(client.publish(collection, event_properties)).to eq(api_response)
88
88
  end
89
89
  end
90
90
  end
@@ -187,7 +187,7 @@ describe Keen::Client::PublishingMethods do
187
187
  EM.run {
188
188
  client.publish_async(collection, event_properties).callback { |response|
189
189
  begin
190
- response.should == api_success
190
+ expect(response).to eq(api_success)
191
191
  ensure
192
192
  EM.stop
193
193
  end
@@ -200,8 +200,8 @@ describe Keen::Client::PublishingMethods do
200
200
  EM.run {
201
201
  client.publish_async(collection, event_properties).errback { |error|
202
202
  begin
203
- error.should_not be_nil
204
- error.message.should == "Keen IO Exception: HTTP publish_async failure: WebMock timeout error"
203
+ expect(error).to_not be_nil
204
+ expect(error.message).to eq("Keen IO Exception: HTTP publish_async failure: WebMock timeout error")
205
205
  ensure
206
206
  EM.stop
207
207
  end
@@ -221,7 +221,7 @@ describe Keen::Client::PublishingMethods do
221
221
  end
222
222
  }
223
223
  }
224
- }.to raise_error
224
+ }.to raise_error(NameError)
225
225
  end
226
226
  end
227
227
  end
@@ -265,7 +265,7 @@ describe Keen::Client::PublishingMethods do
265
265
  EM.run {
266
266
  client.publish_batch_async(events).callback { |response|
267
267
  begin
268
- response.should == api_success
268
+ expect(response).to eq(api_success)
269
269
  ensure
270
270
  EM.stop
271
271
  end
@@ -278,8 +278,8 @@ describe Keen::Client::PublishingMethods do
278
278
  EM.run {
279
279
  client.publish_batch_async(events).errback { |error|
280
280
  begin
281
- error.should_not be_nil
282
- error.message.should == "Keen IO Exception: HTTP publish_async failure: WebMock timeout error"
281
+ expect(error).to_not be_nil
282
+ expect(error.message).to eq("Keen IO Exception: HTTP publish_async failure: WebMock timeout error")
283
283
  ensure
284
284
  EM.stop
285
285
  end
@@ -299,7 +299,7 @@ describe Keen::Client::PublishingMethods do
299
299
  end
300
300
  }
301
301
  }
302
- }.to raise_error
302
+ }.to raise_error(NameError)
303
303
  end
304
304
  end
305
305
  end
@@ -313,22 +313,20 @@ describe Keen::Client::PublishingMethods do
313
313
 
314
314
  describe "#add_event" do
315
315
  it "should alias to publish" do
316
- client.should_receive(:publish).with("users", {:a => 1}, {:b => 2})
317
- client.add_event("users", {:a => 1}, {:b => 2})
316
+ expect(client).to receive(:publish).with(collection, {:a => 1})
317
+ client.add_event(collection, {:a => 1}, {:b => 2})
318
318
  end
319
319
  end
320
320
 
321
321
  describe "beacon_url" do
322
322
  it "should return a url with a base-64 encoded json param" do
323
- client.beacon_url("sign_ups", { :name => "Bob" }).should ==
324
- "#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0="
323
+ expect(client.beacon_url("sign_ups", { :name => "Bob" })).to eq("#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0=")
325
324
  end
326
325
  end
327
326
 
328
327
  describe "redirect_url" do
329
328
  it "should return a url with a base-64 encoded json param and an encoded redirect url" do
330
- client.redirect_url("sign_ups", { :name => "Bob" }, "http://keen.io/?foo=bar&bar=baz").should ==
331
- "#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0=&redirect=http%3A%2F%2Fkeen.io%2F%3Ffoo%3Dbar%26bar%3Dbaz"
329
+ expect(client.redirect_url("sign_ups", { :name => "Bob" }, "http://keen.io/?foo=bar&bar=baz")).to eq("#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0=&redirect=http%3A%2F%2Fkeen.io%2F%3Ffoo%3Dbar%26bar%3Dbaz")
332
330
  end
333
331
  end
334
332
 
@@ -19,14 +19,14 @@ describe Keen::Client do
19
19
 
20
20
  ["minimum", "maximum", "sum", "average", "count", "count_unique", "select_unique", "extraction", "multi_analysis", "median", "percentile"].each do |query_name|
21
21
  it "should call keen query passing the query name" do
22
- client.should_receive(:query).with(query_name.to_sym, event_collection, params, {})
22
+ expect(client).to receive(:query).with(query_name.to_sym, event_collection, params, {})
23
23
  client.send(query_name, event_collection, params)
24
24
  end
25
25
  end
26
26
 
27
27
  describe "funnel" do
28
28
  it "should call keen query w/o event collection" do
29
- client.should_receive(:query).with(:funnel, nil, params, {})
29
+ expect(client).to receive(:query).with(:funnel, nil, params, {})
30
30
  client.funnel(params)
31
31
  end
32
32
  end
@@ -58,7 +58,7 @@ describe Keen::Client do
58
58
  expected_url = query_url(query_name, expected_query_params)
59
59
  stub_keen_get(expected_url, 200, :result => 1)
60
60
  response = query.call(query_name, event_collection, extra_query_hash)
61
- response.should == api_response["result"]
61
+ expect(response).to eq(api_response["result"])
62
62
  expect_keen_get(expected_url, "sync", read_key)
63
63
  end
64
64
 
@@ -138,14 +138,14 @@ describe Keen::Client do
138
138
  timeframe_str = CGI.escape(MultiJson.encode(timeframe))
139
139
 
140
140
  test_query("&timeframe=#{timeframe_str}", options = {:timeframe => timeframe})
141
- options.should eq({:timeframe => timeframe})
141
+ expect(options).to eq({:timeframe => timeframe})
142
142
  end
143
143
 
144
144
  it "should return the full API response if the response option is set to all_keys" do
145
145
  expected_url = query_url("funnel", "?steps=#{MultiJson.encode([])}")
146
146
  stub_keen_get(expected_url, 200, :result => [1])
147
147
  api_response = query.call("funnel", nil, { :steps => [] }, { :response => :all_keys })
148
- api_response.should == { "result" => [1] }
148
+ expect(api_response).to eq({ "result" => [1] })
149
149
  end
150
150
 
151
151
  it "should call API with post body if method opton is set to post " do
@@ -158,7 +158,22 @@ describe Keen::Client do
158
158
  response = query.call("funnel", nil, { :steps => steps }, { :method => :post })
159
159
 
160
160
  expect_keen_post(expected_url, { :steps => steps }, "sync", read_key)
161
- response.should == api_response["result"]
161
+ expect(response).to eq(api_response["result"])
162
+ end
163
+
164
+ it "should add extra headers if you supply them as an option" do
165
+ url = query_url("count", "?event_collection=#{event_collection}")
166
+ extra_headers = {
167
+ "Keen-Flibbity-Flabbidy" => "foobar"
168
+ }
169
+
170
+ options = {
171
+ :headers => extra_headers
172
+ }
173
+
174
+ stub_keen_get(url, 200, :result => 10)
175
+ client.count(event_collection, {}, options)
176
+ expect_keen_get(url, "sync", read_key, extra_headers)
162
177
  end
163
178
  end
164
179
  end
@@ -171,14 +186,14 @@ describe Keen::Client do
171
186
  end
172
187
 
173
188
  it "should not require params" do
174
- client.count(event_collection).should == 10
189
+ expect(client.count(event_collection)).to eq(10)
175
190
  expect_keen_get(url, "sync", read_key)
176
191
  end
177
192
 
178
193
  context "with event collection as symbol" do
179
194
  let(:event_collection) { :users }
180
195
  it "should not require a string" do
181
- client.count(event_collection).should == 10
196
+ expect(client.count(event_collection)).to eq(10)
182
197
  end
183
198
  end
184
199
  end
@@ -188,7 +203,7 @@ describe Keen::Client do
188
203
  query_params = "?event_collection=#{event_collection}"
189
204
  url = query_url("extraction", query_params)
190
205
  stub_keen_get(url, 200, :result => { "a" => 1 } )
191
- client.extraction(event_collection).should == { "a" => 1 }
206
+ expect(client.extraction(event_collection)).to eq({ "a" => 1 })
192
207
  expect_keen_get(url, "sync", read_key)
193
208
  end
194
209
  end
@@ -207,7 +222,7 @@ describe Keen::Client do
207
222
  end
208
223
 
209
224
  it "should not run the query" do
210
- Keen::HTTP::Sync.should_not receive(:new)
225
+ expect(Keen::HTTP::Sync).to_not receive(:new)
211
226
  end
212
227
  end
213
228
  end
@@ -20,9 +20,9 @@ describe Keen::Client do
20
20
  context "deprecated" do
21
21
  it "should allow created via project_id and key args" do
22
22
  client = Keen::Client.new(project_id, write_key, read_key)
23
- client.write_key.should == write_key
24
- client.read_key.should == read_key
25
- client.project_id.should == project_id
23
+ expect(client.write_key).to eq(write_key)
24
+ expect(client.read_key).to eq(read_key)
25
+ expect(client.project_id).to eq(project_id)
26
26
  end
27
27
  end
28
28
 
@@ -33,15 +33,15 @@ describe Keen::Client do
33
33
  :read_key => read_key,
34
34
  :api_url => api_url,
35
35
  :read_timeout => read_timeout)
36
- client.write_key.should == write_key
37
- client.read_key.should == read_key
38
- client.project_id.should == project_id
39
- client.api_url.should == api_url
40
- client.read_timeout.should == read_timeout
36
+ expect(client.write_key).to eq(write_key)
37
+ expect(client.read_key).to eq(read_key)
38
+ expect(client.project_id).to eq(project_id)
39
+ expect(client.api_url).to eq(api_url)
40
+ expect(client.read_timeout).to eq(read_timeout)
41
41
  end
42
42
 
43
43
  it "should set a default api_url" do
44
- Keen::Client.new.api_url.should == "https://api.keen.io"
44
+ expect(Keen::Client.new.api_url).to eq("https://api.keen.io")
45
45
  end
46
46
  end
47
47
 
@@ -51,11 +51,11 @@ describe Keen::Client do
51
51
  let (:process_response) { client.method(:process_response) }
52
52
 
53
53
  it "should return encoded json for a 200" do
54
- process_response.call(200, body).should == { "wazzup" => 1 }
54
+ expect(process_response.call(200, body)).to eq({ "wazzup" => 1 })
55
55
  end
56
56
 
57
57
  it "should return encoded json for a 201" do
58
- process_response.call(201, body).should == { "wazzup" => 1 }
58
+ expect(process_response.call(201, body)).to eq({ "wazzup" => 1 })
59
59
  end
60
60
 
61
61
  it "should return empty for bad json on a 200/201" do
@@ -17,31 +17,31 @@ describe Keen do
17
17
  let(:client) { Keen.send(:default_client) }
18
18
 
19
19
  it "should set a project id from the environment" do
20
- client.project_id.should == "12345"
20
+ expect(client.project_id).to eq("12345")
21
21
  end
22
22
 
23
23
  it "should set a write key from the environment" do
24
- client.write_key.should == "abcdewrite"
24
+ expect(client.write_key).to eq("abcdewrite")
25
25
  end
26
26
 
27
27
  it "should set a read key from the environment" do
28
- client.read_key.should == "abcderead"
28
+ expect(client.read_key).to eq("abcderead")
29
29
  end
30
30
 
31
31
  it "should set a master key from the environment" do
32
- client.master_key.should == "lalalala"
32
+ expect(client.master_key).to eq("lalalala")
33
33
  end
34
34
 
35
35
  it "should set an api host from the environment" do
36
- client.api_url.should == "http://fake.keen.io:fakeport"
36
+ expect(client.api_url).to eq("http://fake.keen.io:fakeport")
37
37
  end
38
38
 
39
39
  it "should set an proxy host from the environment" do
40
- client.proxy_url.should == "http://proxy.keen.io:proxyport"
40
+ expect(client.proxy_url).to eq("http://proxy.keen.io:proxyport")
41
41
  end
42
42
 
43
43
  it "should set an proxy type from the environment" do
44
- client.proxy_type.should == "http"
44
+ expect(client.proxy_type).to eq("http")
45
45
  end
46
46
  end
47
47
  end
@@ -49,7 +49,7 @@ describe Keen do
49
49
  describe "Keen delegation" do
50
50
  it "should memoize the default client, retaining settings" do
51
51
  Keen.project_id = "new-abcde"
52
- Keen.project_id.should == "new-abcde"
52
+ expect(Keen.project_id).to eq("new-abcde")
53
53
  end
54
54
 
55
55
  after do
@@ -60,33 +60,33 @@ describe Keen do
60
60
  describe "forwardable" do
61
61
  before do
62
62
  @default_client = double("client")
63
- Keen.stub(:default_client).and_return(@default_client)
63
+ allow(Keen).to receive(:default_client).and_return(@default_client)
64
64
  end
65
65
 
66
66
  [:project_id, :write_key, :read_key, :api_url, :proxy_url, :proxy_type].each do |_method|
67
67
  it "should forward the #{_method} method" do
68
- @default_client.should_receive(_method)
68
+ expect(@default_client).to receive(_method)
69
69
  Keen.send(_method)
70
70
  end
71
71
  end
72
72
 
73
73
  [:project_id, :write_key, :read_key, :master_key, :api_url].each do |_method|
74
74
  it "should forward the #{_method} method" do
75
- @default_client.should_receive(_method)
75
+ expect(@default_client).to receive(_method)
76
76
  Keen.send(_method)
77
77
  end
78
78
  end
79
79
 
80
80
  [:project_id=, :write_key=, :read_key=, :master_key=, :api_url=].each do |_method|
81
81
  it "should forward the #{_method} method" do
82
- @default_client.should_receive(_method).with("12345")
82
+ expect(@default_client).to receive(_method).with("12345")
83
83
  Keen.send(_method, "12345")
84
84
  end
85
85
  end
86
86
 
87
87
  [:publish, :publish_async, :publish_batch, :publish_batch_async].each do |_method|
88
88
  it "should forward the #{_method} method" do
89
- @default_client.should_receive(_method).with("users", {})
89
+ expect(@default_client).to receive(_method).with("users", {})
90
90
  Keen.send(_method, "users", {})
91
91
  end
92
92
  end
@@ -95,7 +95,7 @@ describe Keen do
95
95
  # any new methods have a corresponding delegator
96
96
  Keen::Client::QueryingMethods.instance_methods.each do |_method|
97
97
  it "should forward the #{_method} query method" do
98
- @default_client.should_receive(_method).with("users", {})
98
+ expect(@default_client).to receive(_method).with("users", {})
99
99
  Keen.send(_method, "users", {})
100
100
  end
101
101
  end
@@ -103,7 +103,7 @@ describe Keen do
103
103
 
104
104
  describe "logger" do
105
105
  it "should be set to info" do
106
- Keen.logger.level.should == Logger::INFO
106
+ expect(Keen.logger.level).to eq(Logger::INFO)
107
107
  end
108
108
  end
109
109
  end
@@ -14,11 +14,11 @@ describe Keen::ScopedKey do
14
14
 
15
15
  describe "constructor" do
16
16
  it "should retain the api_key" do
17
- new_scoped_key.api_key.should == api_key
17
+ expect(new_scoped_key.api_key).to eq(api_key)
18
18
  end
19
19
 
20
20
  it "should retain the data" do
21
- new_scoped_key.data.should == data
21
+ expect(new_scoped_key.data).to eq(data)
22
22
  end
23
23
  end
24
24
 
@@ -26,19 +26,19 @@ describe Keen::ScopedKey do
26
26
  it "should encrypt and hex encode the data using the api key" do
27
27
  encrypted_str = new_scoped_key.encrypt!
28
28
  other_api_key = Keen::ScopedKey.decrypt!(api_key, encrypted_str)
29
- other_api_key.data.should == data
29
+ expect(other_api_key.data).to eq(data)
30
30
  end
31
31
 
32
32
  describe "when an IV is not provided" do
33
33
  it "should not produce the same encrypted key text" do
34
- new_scoped_key.encrypt!.should_not == (new_scoped_key.encrypt!)
34
+ expect(new_scoped_key.encrypt!).to_not eq(new_scoped_key.encrypt!)
35
35
  end
36
36
  end
37
37
 
38
38
  describe "when an IV is provided" do
39
39
  it "should produce the same encrypted key text for a " do
40
40
  iv = "\0" * 16
41
- new_scoped_key.encrypt!(iv).should == (new_scoped_key.encrypt!(iv))
41
+ expect(new_scoped_key.encrypt!(iv)).to eq(new_scoped_key.encrypt!(iv))
42
42
  end
43
43
 
44
44
  it "should raise error when an invalid IV is supplied" do
@@ -14,11 +14,11 @@ describe Keen::ScopedKey do
14
14
 
15
15
  describe "constructor" do
16
16
  it "should retain the api_key" do
17
- new_scoped_key.api_key.should == api_key
17
+ expect(new_scoped_key.api_key).to eq(api_key)
18
18
  end
19
19
 
20
20
  it "should retain the data" do
21
- new_scoped_key.data.should == data
21
+ expect(new_scoped_key.data).to eq(data)
22
22
  end
23
23
  end
24
24
 
@@ -26,19 +26,19 @@ describe Keen::ScopedKey do
26
26
  it "should encrypt and hex encode the data using the api key" do
27
27
  encrypted_str = new_scoped_key.encrypt!
28
28
  other_api_key = Keen::ScopedKey.decrypt!(api_key, encrypted_str)
29
- other_api_key.data.should == data
29
+ expect(other_api_key.data).to eq(data)
30
30
  end
31
31
 
32
32
  describe "when an IV is not provided" do
33
33
  it "should not produce the same encrypted key text" do
34
- new_scoped_key.encrypt!.should_not == (new_scoped_key.encrypt!)
34
+ expect(new_scoped_key.encrypt!).to_not eq(new_scoped_key.encrypt!)
35
35
  end
36
36
  end
37
37
 
38
38
  describe "when an IV is provided" do
39
39
  it "should produce the same encrypted key text for a " do
40
40
  iv = "\0" * 16
41
- new_scoped_key.encrypt!(iv).should == (new_scoped_key.encrypt!(iv))
41
+ expect(new_scoped_key.encrypt!(iv)).to eq(new_scoped_key.encrypt!(iv))
42
42
  end
43
43
 
44
44
  it "should raise error when an invalid IV is supplied" do
@@ -31,7 +31,7 @@ module Keen::SpecHelpers
31
31
  stub_keen_request(:delete, url, status, "")
32
32
  end
33
33
 
34
- def expect_keen_request(method, url, body, sync_or_async_ua, read_or_write_key)
34
+ def expect_keen_request(method, url, body, sync_or_async_ua, read_or_write_key, extra_headers={})
35
35
  user_agent = "keen-gem, v#{Keen::VERSION}, #{sync_or_async_ua}"
36
36
  user_agent += ", #{RUBY_VERSION}, #{RUBY_PLATFORM}, #{RUBY_PATCHLEVEL}"
37
37
  if defined?(RUBY_ENGINE)
@@ -43,22 +43,24 @@ module Keen::SpecHelpers
43
43
  "Authorization" => read_or_write_key,
44
44
  "Keen-Sdk" => "ruby-#{Keen::VERSION}" }
45
45
 
46
- WebMock.should have_requested(method, url).with(
46
+ headers = headers.merge(extra_headers) if not extra_headers.empty?
47
+
48
+ expect(WebMock).to have_requested(method, url).with(
47
49
  :body => body,
48
50
  :headers => headers)
49
51
 
50
52
  end
51
53
 
52
- def expect_keen_get(url, sync_or_async_ua, read_key)
53
- expect_keen_request(:get, url, "", sync_or_async_ua, read_key)
54
+ def expect_keen_get(url, sync_or_async_ua, read_key, extra_headers={})
55
+ expect_keen_request(:get, url, "", sync_or_async_ua, read_key, extra_headers)
54
56
  end
55
57
 
56
- def expect_keen_post(url, event_properties, sync_or_async_ua, write_key)
57
- expect_keen_request(:post, url, MultiJson.encode(event_properties), sync_or_async_ua, write_key)
58
+ def expect_keen_post(url, event_properties, sync_or_async_ua, write_key, extra_headers={})
59
+ expect_keen_request(:post, url, MultiJson.encode(event_properties), sync_or_async_ua, write_key, extra_headers)
58
60
  end
59
61
 
60
- def expect_keen_delete(url, sync_or_async_ua, master_key)
61
- expect_keen_request(:delete, url, "", sync_or_async_ua, master_key)
62
+ def expect_keen_delete(url, sync_or_async_ua, master_key, extra_headers={})
63
+ expect_keen_request(:delete, url, "", sync_or_async_ua, master_key, extra_headers)
62
64
  end
63
65
 
64
66
  def api_event_collection_resource_url(base_url, collection)
@@ -77,4 +79,3 @@ RSpec.configure do |config|
77
79
  config.tty = true
78
80
  config.formatter = :progress # :progress, :documentation, :html, :textmate
79
81
  end
80
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kleissner
@@ -9,157 +9,143 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-26 00:00:00.000000000 Z
12
+ date: 2017-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: addressable
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: 2.3.5
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.3.5
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: guard
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2.14'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2.14'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: guard-rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '4.7'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '4.7'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rb-inotify
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0.9'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.9'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rb-fsevent
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0.9'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0.9'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rb-fchange
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.0.6
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.0.6
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: ruby_gntp
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ~>
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0.3'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0.3'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rb-readline
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ~>
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.5'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ~>
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0.5'
140
- - !ruby/object:Gem::Dependency
141
- name: debugger
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ! '>='
145
- - !ruby/object:Gem::Version
146
- version: '0'
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ! '>='
152
- - !ruby/object:Gem::Version
153
- version: '0'
154
140
  description: Send events and build analytics features into your Ruby applications.
155
141
  email: opensource@keen.io
156
142
  executables: []
157
143
  extensions: []
158
144
  extra_rdoc_files: []
159
145
  files:
160
- - .gitignore
161
- - .rspec
162
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
163
149
  - Gemfile
164
150
  - Guardfile
165
151
  - LICENSE
@@ -203,17 +189,17 @@ require_paths:
203
189
  - lib
204
190
  required_ruby_version: !ruby/object:Gem::Requirement
205
191
  requirements:
206
- - - ! '>='
192
+ - - ">="
207
193
  - !ruby/object:Gem::Version
208
194
  version: '0'
209
195
  required_rubygems_version: !ruby/object:Gem::Requirement
210
196
  requirements:
211
- - - ! '>='
197
+ - - ">="
212
198
  - !ruby/object:Gem::Version
213
199
  version: '0'
214
200
  requirements: []
215
201
  rubyforge_project:
216
- rubygems_version: 2.6.8
202
+ rubygems_version: 2.4.5.1
217
203
  signing_key:
218
204
  specification_version: 4
219
205
  summary: Keen IO API Client