keen 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  *.bundle
2
- Gemfile.lock
3
2
  tmp
4
3
  .env
5
4
  log
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ keen (0.7.1)
5
+ multi_json (~> 1.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ addressable (2.3.4)
11
+ coderay (1.0.9)
12
+ columnize (0.3.6)
13
+ cookiejar (0.3.0)
14
+ crack (0.3.2)
15
+ debugger (1.5.0)
16
+ columnize (>= 0.3.1)
17
+ debugger-linecache (~> 1.2.0)
18
+ debugger-ruby_core_source (~> 1.2.0)
19
+ debugger-linecache (1.2.0)
20
+ debugger-ruby_core_source (1.2.0)
21
+ diff-lcs (1.2.4)
22
+ em-http-request (1.0.3)
23
+ addressable (>= 2.2.3)
24
+ cookiejar
25
+ em-socksify
26
+ eventmachine (>= 1.0.0.beta.4)
27
+ http_parser.rb (>= 0.5.3)
28
+ em-socksify (0.2.1)
29
+ eventmachine (>= 1.0.0.beta.4)
30
+ em-synchrony (1.0.3)
31
+ eventmachine (>= 1.0.0.beta.1)
32
+ eventmachine (1.0.3)
33
+ ffi (1.8.1)
34
+ formatador (0.2.4)
35
+ guard (1.8.0)
36
+ formatador (>= 0.2.4)
37
+ listen (>= 1.0.0)
38
+ lumberjack (>= 1.0.2)
39
+ pry (>= 0.9.10)
40
+ thor (>= 0.14.6)
41
+ guard-rspec (2.6.0)
42
+ guard (>= 1.8)
43
+ rspec (~> 2.13)
44
+ http_parser.rb (0.5.3)
45
+ linecache (0.46)
46
+ rbx-require-relative (> 0.0.4)
47
+ listen (1.0.3)
48
+ rb-fsevent (>= 0.9.3)
49
+ rb-inotify (>= 0.9)
50
+ rb-kqueue (>= 0.2)
51
+ lumberjack (1.0.3)
52
+ method_source (0.8.1)
53
+ multi_json (1.7.2)
54
+ pry (0.9.12.1)
55
+ coderay (~> 1.0.5)
56
+ method_source (~> 0.8)
57
+ slop (~> 3.4)
58
+ rake (10.0.4)
59
+ rb-fchange (0.0.6)
60
+ ffi
61
+ rb-fsevent (0.9.3)
62
+ rb-inotify (0.9.0)
63
+ ffi (>= 0.5.0)
64
+ rb-kqueue (0.2.0)
65
+ ffi (>= 0.5.0)
66
+ rb-readline (0.5.0)
67
+ rbx-require-relative (0.0.9)
68
+ rspec (2.13.0)
69
+ rspec-core (~> 2.13.0)
70
+ rspec-expectations (~> 2.13.0)
71
+ rspec-mocks (~> 2.13.0)
72
+ rspec-core (2.13.1)
73
+ rspec-expectations (2.13.0)
74
+ diff-lcs (>= 1.1.3, < 2.0)
75
+ rspec-mocks (2.13.1)
76
+ ruby-debug (0.10.4)
77
+ columnize (>= 0.1)
78
+ ruby-debug-base (~> 0.10.4.0)
79
+ ruby-debug-base (0.10.4)
80
+ linecache (>= 0.3)
81
+ ruby_gntp (0.3.4)
82
+ slop (3.4.4)
83
+ thor (0.18.1)
84
+ webmock (1.11.0)
85
+ addressable (>= 2.2.7)
86
+ crack (>= 0.3.2)
87
+
88
+ PLATFORMS
89
+ ruby
90
+
91
+ DEPENDENCIES
92
+ debugger
93
+ em-http-request
94
+ em-synchrony
95
+ guard
96
+ guard-rspec
97
+ keen!
98
+ rake
99
+ rb-fchange
100
+ rb-fsevent
101
+ rb-inotify
102
+ rb-readline
103
+ rspec
104
+ ruby-debug
105
+ ruby_gntp
106
+ webmock
data/README.md CHANGED
@@ -177,6 +177,9 @@ To track email opens, simply add an image to your email template that points to
177
177
 
178
178
  ### Changelog
179
179
 
180
+ ##### 0.7.1
181
+ + Allow configuration of the base API URL via the KEEN_API_URL environment variable. Useful for local testing and proxies.
182
+
180
183
  ##### 0.7.0
181
184
  + BREAKING CHANGE! Added support for read and write scoped keys to reflect the new Keen IO security architecture.
182
185
  The advantage of scoped keys is finer grained permission control. Public clients that
@@ -25,9 +25,18 @@ module Keen
25
25
  class << self
26
26
  extend Forwardable
27
27
 
28
- def_delegators :default_client, :project_id, :write_key, :read_key,
29
- :project_id=, :write_key=, :read_key=, :publish, :publish_async,
30
- :beacon_url, :count, :count_unique, :minimum, :maximum,
28
+ def_delegators :default_client,
29
+ :project_id, :project_id=,
30
+ :write_key, :write_key=,
31
+ :read_key, :read_key=,
32
+ :api_url, :api_url=
33
+
34
+ def_delegators :default_client,
35
+ :publish, :publish_async,
36
+ :beacon_url
37
+
38
+ def_delegators :default_client,
39
+ :count, :count_unique, :minimum, :maximum,
31
40
  :sum, :average, :select_unique, :funnel, :extraction
32
41
 
33
42
  attr_writer :logger
@@ -46,7 +55,8 @@ module Keen
46
55
  @default_client ||= Keen::Client.new(
47
56
  :project_id => ENV['KEEN_PROJECT_ID'],
48
57
  :write_key => ENV['KEEN_WRITE_KEY'],
49
- :read_key => ENV['KEEN_READ_KEY']
58
+ :read_key => ENV['KEEN_READ_KEY'],
59
+ :api_url => ENV['KEEN_API_URL']
50
60
  )
51
61
  end
52
62
  end
@@ -6,18 +6,16 @@ require 'keen/client/querying_methods'
6
6
  require 'openssl'
7
7
  require 'multi_json'
8
8
  require 'base64'
9
- require 'uri'
10
9
 
11
10
  module Keen
12
11
  class Client
13
12
  include Keen::Client::PublishingMethods
14
13
  include Keen::Client::QueryingMethods
15
14
 
16
- attr_accessor :project_id, :write_key, :read_key
15
+ attr_accessor :project_id, :write_key, :read_key, :api_url
17
16
 
18
17
  CONFIG = {
19
- :api_host => "api.keen.io",
20
- :api_port => 443,
18
+ :api_url => "https://api.keen.io",
21
19
  :api_version => "3.0",
22
20
  :api_sync_http_options => {
23
21
  :use_ssl => true,
@@ -48,8 +46,10 @@ module Keen
48
46
  }.merge(args[3] || {})
49
47
  end
50
48
 
51
- @project_id, @write_key, @read_key = options.values_at(
49
+ self.project_id, self.write_key, self.read_key = options.values_at(
52
50
  :project_id, :write_key, :read_key)
51
+
52
+ self.api_url = options[:api_url] || CONFIG[:api_url]
53
53
  end
54
54
 
55
55
  private
@@ -28,7 +28,7 @@ module Keen
28
28
 
29
29
  begin
30
30
  response = Keen::HTTP::Sync.new(
31
- api_host, api_port, api_sync_http_options).post(
31
+ self.api_url, api_sync_http_options).post(
32
32
  :path => api_event_resource_path(event_collection),
33
33
  :headers => api_headers(self.write_key, "sync"),
34
34
  :body => MultiJson.encode(properties))
@@ -53,7 +53,7 @@ module Keen
53
53
 
54
54
  deferrable = EventMachine::DefaultDeferrable.new
55
55
 
56
- http_client = Keen::HTTP::Async.new(api_host, api_port, api_async_http_options)
56
+ http_client = Keen::HTTP::Async.new(self.api_url, api_async_http_options)
57
57
  http = http_client.post(
58
58
  :path => api_event_resource_path(event_collection),
59
59
  :headers => api_headers(self.write_key, "async"),
@@ -98,7 +98,7 @@ module Keen
98
98
  def beacon_url(event_collection, properties)
99
99
  json = MultiJson.encode(properties)
100
100
  data = [json].pack("m0").tr("+/", "-_").gsub("\n", "")
101
- "https://#{api_host}#{api_event_resource_path(event_collection)}?api_key=#{self.write_key}&data=#{data}"
101
+ "#{self.api_url}#{api_event_resource_path(event_collection)}?api_key=#{self.write_key}&data=#{data}"
102
102
  end
103
103
 
104
104
  private
@@ -172,7 +172,7 @@ module Keen
172
172
 
173
173
  begin
174
174
  response = Keen::HTTP::Sync.new(
175
- api_host, api_port, api_sync_http_options).get(
175
+ self.api_url, api_sync_http_options).get(
176
176
  :path => "#{api_query_resource_path(query_name)}?#{query_params}",
177
177
  :headers => api_headers(self.read_key, "sync"))
178
178
  rescue Exception => http_error
@@ -1,9 +1,12 @@
1
1
  module Keen
2
2
  module HTTP
3
3
  class Sync
4
- def initialize(host, port, options={})
4
+ def initialize(base_url, options={})
5
+ require 'uri'
5
6
  require 'net/https'
6
- @http = Net::HTTP.new(host, port)
7
+
8
+ uri = URI.parse(base_url)
9
+ @http = Net::HTTP.new(uri.host, uri.port)
7
10
  options.each_pair { |key, value| @http.send "#{key}=", value }
8
11
  end
9
12
 
@@ -21,20 +24,20 @@ module Keen
21
24
  end
22
25
 
23
26
  class Async
24
- def initialize(host, port, options={})
27
+ def initialize(base_url, options={})
25
28
  if defined?(EventMachine) && EventMachine.reactor_running?
26
29
  require 'em-http-request'
27
30
  else
28
31
  raise Error, "An EventMachine loop must be running to use publish_async calls"
29
32
  end
30
33
 
31
- @host, @port, @http_options = host, port, options
34
+ @base_url, @http_options = base_url, options
32
35
  end
33
36
 
34
37
  def post(options)
35
38
  path, headers, body = options.values_at(
36
39
  :path, :headers, :body)
37
- uri = "https://#{@host}:#{@port}#{path}"
40
+ uri = "#{@base_url}#{path}"
38
41
  http_client = EventMachine::HttpRequest.new(uri, @http_options)
39
42
  http_client.post(
40
43
  :body => body,
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -35,8 +35,14 @@ describe "Keen IO API" do
35
35
  it "should publish the event and trigger callbacks" do
36
36
  EM.run {
37
37
  Keen.publish_async(collection, event_properties).callback { |response|
38
- response.should == api_success
38
+ begin
39
+ response.should == api_success
40
+ ensure
41
+ EM.stop
42
+ end
43
+ }.errback { |error|
39
44
  EM.stop
45
+ fail error
40
46
  }
41
47
  }
42
48
  end
@@ -44,8 +50,11 @@ describe "Keen IO API" do
44
50
  it "should publish to non-url-safe collections" do
45
51
  EM.run {
46
52
  Keen.publish_async("foo bar", event_properties).callback { |response|
47
- response.should == api_success
48
- EM.stop
53
+ begin
54
+ response.should == api_success
55
+ ensure
56
+ EM.stop
57
+ end
49
58
  }
50
59
  }
51
60
  end
@@ -55,19 +64,22 @@ describe "Keen IO API" do
55
64
 
56
65
  describe "queries" do
57
66
  let(:read_key) { ENV['KEEN_READ_KEY'] }
58
- let(:event_collection) { "purchases_" + rand(100000).to_s }
59
- let(:returns_event_collection) { "returns_" + rand(100000).to_s }
67
+ let(:event_collection) { @event_collection }
68
+ let(:returns_event_collection) { @returns_event_collection }
60
69
 
61
70
  before(:all) do
62
- Keen.publish(event_collection, {
71
+ @event_collection = "purchases_" + rand(100000).to_s
72
+ @returns_event_collection = "returns_" + rand(100000).to_s
73
+
74
+ Keen.publish(@event_collection, {
63
75
  :username => "bob",
64
76
  :price => 10
65
77
  })
66
- Keen.publish(event_collection, {
78
+ Keen.publish(@event_collection, {
67
79
  :username => "ted",
68
80
  :price => 20
69
81
  })
70
- Keen.publish(returns_event_collection, {
82
+ Keen.publish(@returns_event_collection, {
71
83
  :username => "bob",
72
84
  :price => 30
73
85
  })
@@ -114,7 +126,7 @@ describe "Keen IO API" do
114
126
  :event_collection => event_collection,
115
127
  :actor_property => "username"
116
128
  }, {
117
- :event_collection => returns_event_collection,
129
+ :event_collection => @returns_event_collection,
118
130
  :actor_property => "username"
119
131
  }]
120
132
  results = Keen.funnel(:steps => steps)
@@ -3,22 +3,24 @@ require File.expand_path("../../spec_helper", __FILE__)
3
3
  describe Keen::Client::PublishingMethods do
4
4
  let(:project_id) { "12345" }
5
5
  let(:write_key) { "abcde" }
6
- let(:api_host) { "api.keen.io" }
6
+ let(:api_url) { "https://unreal.keen.io" }
7
7
  let(:collection) { "users" }
8
8
  let(:event_properties) { { "name" => "Bob" } }
9
9
  let(:api_success) { { "created" => true } }
10
- let(:client) { Keen::Client.new(:project_id => project_id, :write_key => write_key) }
10
+ let(:client) { Keen::Client.new(
11
+ :project_id => project_id, :write_key => write_key,
12
+ :api_url => api_url) }
11
13
 
12
14
  describe "publish" do
13
15
  it "should post using the collection and properties" do
14
- stub_keen_post(api_event_resource_url(collection), 201, "")
16
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, "")
15
17
  client.publish(collection, event_properties)
16
- expect_keen_post(api_event_resource_url(collection), event_properties, "sync", write_key)
18
+ expect_keen_post(api_event_resource_url(api_url, collection), event_properties, "sync", write_key)
17
19
  end
18
20
 
19
21
  it "should return the proper response" do
20
22
  api_response = { "created" => true }
21
- stub_keen_post(api_event_resource_url(collection), 201, api_response)
23
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, api_response)
22
24
  client.publish(collection, event_properties).should == api_response
23
25
  end
24
26
 
@@ -35,13 +37,13 @@ describe Keen::Client::PublishingMethods do
35
37
  end
36
38
 
37
39
  it "should url encode the event collection" do
38
- stub_keen_post(api_event_resource_url("foo%20bar"), 201, "")
40
+ stub_keen_post(api_event_resource_url(api_url, "foo%20bar"), 201, "")
39
41
  client.publish("foo bar", event_properties)
40
- expect_keen_post(api_event_resource_url("foo%20bar"), event_properties, "sync", write_key)
42
+ expect_keen_post(api_event_resource_url(api_url, "foo%20bar"), event_properties, "sync", write_key)
41
43
  end
42
44
 
43
45
  it "should wrap exceptions" do
44
- stub_request(:post, api_event_resource_url(collection)).to_timeout
46
+ stub_request(:post, api_event_resource_url(api_url, collection)).to_timeout
45
47
  e = nil
46
48
  begin
47
49
  client.publish(collection, event_properties)
@@ -81,27 +83,33 @@ describe Keen::Client::PublishingMethods do
81
83
  end
82
84
 
83
85
  it "should post the event data" do
84
- stub_keen_post(api_event_resource_url(collection), 201, api_success)
86
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, api_success)
85
87
  EM.run {
86
88
  client.publish_async(collection, event_properties).callback {
87
89
  begin
88
- expect_keen_post(api_event_resource_url(collection), event_properties, "async", write_key)
90
+ expect_keen_post(api_event_resource_url(api_url, collection), event_properties, "async", write_key)
89
91
  ensure
90
92
  EM.stop
91
93
  end
94
+ }.errback {
95
+ EM.stop
96
+ fail
92
97
  }
93
98
  }
94
99
  end
95
100
 
96
101
  it "should uri encode the event collection" do
97
- stub_keen_post(api_event_resource_url("foo%20bar"), 201, api_success)
102
+ stub_keen_post(api_event_resource_url(api_url, "foo%20bar"), 201, api_success)
98
103
  EM.run {
99
104
  client.publish_async("foo bar", event_properties).callback {
100
105
  begin
101
- expect_keen_post(api_event_resource_url("foo%20bar"), event_properties, "async", write_key)
106
+ expect_keen_post(api_event_resource_url(api_url, "foo%20bar"), event_properties, "async", write_key)
102
107
  ensure
103
108
  EM.stop
104
109
  end
110
+ }.errback {
111
+ EM.stop
112
+ fail
105
113
  }
106
114
  }
107
115
  end
@@ -120,7 +128,7 @@ describe Keen::Client::PublishingMethods do
120
128
 
121
129
  describe "deferrable callbacks" do
122
130
  it "should trigger callbacks" do
123
- stub_keen_post(api_event_resource_url(collection), 201, api_success)
131
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, api_success)
124
132
  EM.run {
125
133
  client.publish_async(collection, event_properties).callback { |response|
126
134
  begin
@@ -133,7 +141,7 @@ describe Keen::Client::PublishingMethods do
133
141
  end
134
142
 
135
143
  it "should trigger errbacks" do
136
- stub_request(:post, api_event_resource_url(collection)).to_timeout
144
+ stub_request(:post, api_event_resource_url(api_url, collection)).to_timeout
137
145
  EM.run {
138
146
  client.publish_async(collection, event_properties).errback { |error|
139
147
  begin
@@ -147,7 +155,7 @@ describe Keen::Client::PublishingMethods do
147
155
  end
148
156
 
149
157
  it "should not trap exceptions in the client callback" do
150
- stub_keen_post(api_event_resource_url("foo%20bar"), 201, api_success)
158
+ stub_keen_post(api_event_resource_url(api_url, "foo%20bar"), 201, api_success)
151
159
  expect {
152
160
  EM.run {
153
161
  client.publish_async("foo bar", event_properties).callback {
@@ -179,9 +187,8 @@ describe Keen::Client::PublishingMethods do
179
187
 
180
188
  describe "beacon_url" do
181
189
  it "should return a url with a base-64 encoded json param" do
182
- client = Keen::Client.new(:project_id => project_id, :write_key => write_key)
183
190
  client.beacon_url("sign_ups", { :name => "Bob" }).should ==
184
- "https://api.keen.io/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0="
191
+ "#{api_url}/3.0/projects/12345/events/sign_ups?api_key=#{write_key}&data=eyJuYW1lIjoiQm9iIn0="
185
192
  end
186
193
  end
187
194
  end
@@ -3,13 +3,15 @@ require File.expand_path("../../spec_helper", __FILE__)
3
3
  describe Keen::Client do
4
4
  let(:project_id) { "12345" }
5
5
  let(:read_key) { "abcde" }
6
- let(:api_host) { "api.keen.io" }
6
+ let(:api_url) { "https://notreal.keen.io" }
7
7
  let(:api_version) { "3.0" }
8
8
  let(:event_collection) { "users" }
9
- let(:client) { Keen::Client.new(:project_id => project_id, :read_key => read_key) }
9
+ let(:client) { Keen::Client.new(
10
+ :project_id => project_id, :read_key => read_key,
11
+ :api_url => api_url ) }
10
12
 
11
13
  def query_url(query_name, query_params)
12
- "https://#{api_host}/#{api_version}/projects/#{project_id}/queries/#{query_name}#{query_params}"
14
+ "#{api_url}/#{api_version}/projects/#{project_id}/queries/#{query_name}#{query_params}"
13
15
  end
14
16
 
15
17
  describe "querying names" do
@@ -4,8 +4,16 @@ describe Keen::Client do
4
4
  let(:project_id) { "12345" }
5
5
  let(:write_key) { "abcdewrite" }
6
6
  let(:read_key) { "abcderead" }
7
+ let(:api_url) { "http://fake.keen.io:fakeport" }
7
8
  let(:client) { Keen::Client.new(:project_id => project_id) }
8
9
 
10
+ before do
11
+ ENV["KEEN_PROJECT_ID"] = nil
12
+ ENV["KEEN_WRITE_KEY"] = nil
13
+ ENV["KEEN_READ_KEY"] = nil
14
+ ENV["KEEN_API_URL"] = nil
15
+ end
16
+
9
17
  describe "#initialize" do
10
18
  context "deprecated" do
11
19
  it "should allow created via project_id and key args" do
@@ -20,10 +28,16 @@ describe Keen::Client do
20
28
  client = Keen::Client.new(
21
29
  :project_id => project_id,
22
30
  :write_key => write_key,
23
- :read_key => read_key)
31
+ :read_key => read_key,
32
+ :api_url => api_url)
24
33
  client.write_key.should == write_key
25
34
  client.read_key.should == read_key
26
35
  client.project_id.should == project_id
36
+ client.api_url.should == api_url
37
+ end
38
+
39
+ it "should set a default api_url" do
40
+ Keen::Client.new.api_url.should == "https://api.keen.io"
27
41
  end
28
42
  end
29
43
 
@@ -8,6 +8,7 @@ describe Keen do
8
8
  ENV["KEEN_PROJECT_ID"] = "12345"
9
9
  ENV["KEEN_WRITE_KEY"] = "abcdewrite"
10
10
  ENV["KEEN_READ_KEY"] = "abcderead"
11
+ ENV["KEEN_API_URL"] = "http://fake.keen.io:fakeport"
11
12
  end
12
13
 
13
14
  let(:client) { Keen.send(:default_client) }
@@ -23,6 +24,10 @@ describe Keen do
23
24
  it "should set a read key from the environment" do
24
25
  client.read_key.should == "abcderead"
25
26
  end
27
+
28
+ it "should set an api host from the environment" do
29
+ client.api_url.should == "http://fake.keen.io:fakeport"
30
+ end
26
31
  end
27
32
  end
28
33
 
@@ -43,14 +48,14 @@ describe Keen do
43
48
  Keen.stub(:default_client).and_return(@default_client)
44
49
  end
45
50
 
46
- [:project_id, :write_key, :read_key].each do |_method|
51
+ [:project_id, :write_key, :read_key, :api_url].each do |_method|
47
52
  it "should forward the #{_method} method" do
48
53
  @default_client.should_receive(_method)
49
54
  Keen.send(_method)
50
55
  end
51
56
  end
52
57
 
53
- [:project_id=, :write_key=, :read_key=].each do |_method|
58
+ [:project_id=, :write_key=, :read_key=, :api_url=].each do |_method|
54
59
  it "should forward the #{_method} method" do
55
60
  @default_client.should_receive(_method).with("12345")
56
61
  Keen.send(_method, "12345")
@@ -48,8 +48,8 @@ module Keen::SpecHelpers
48
48
  expect_keen_request(:post, url, MultiJson.encode(event_properties), sync_or_async_ua, write_key)
49
49
  end
50
50
 
51
- def api_event_resource_url(collection)
52
- "https://api.keen.io/3.0/projects/#{project_id}/events/#{collection}"
51
+ def api_event_resource_url(base_url, collection)
52
+ "#{base_url}/3.0/projects/#{project_id}/events/#{collection}"
53
53
  end
54
54
  end
55
55
 
@@ -4,26 +4,29 @@ describe Keen::HTTP::Async do
4
4
  let(:project_id) { "12345" }
5
5
  let(:write_key) { "abcdewrite" }
6
6
  let(:collection) { "users" }
7
+ let(:api_url) { "https://fake.keen.io" }
7
8
  let(:event_properties) { { "name" => "Bob" } }
8
9
  let(:api_success) { { "created" => true } }
9
10
 
10
11
  describe "synchrony" do
11
12
  before do
12
- @client = Keen::Client.new(:project_id => project_id, :write_key => write_key)
13
+ @client = Keen::Client.new(
14
+ :project_id => project_id, :write_key => write_key,
15
+ :api_url => api_url)
13
16
  end
14
17
 
15
18
  describe "success" do
16
19
  it "should post the event data" do
17
- stub_keen_post(api_event_resource_url(collection), 201, api_success)
20
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, api_success)
18
21
  EM.synchrony {
19
22
  @client.publish_async(collection, event_properties)
20
- expect_keen_post(api_event_resource_url(collection), event_properties, "async", write_key)
23
+ expect_keen_post(api_event_resource_url(api_url, collection), event_properties, "async", write_key)
21
24
  EM.stop
22
25
  }
23
26
  end
24
27
 
25
28
  it "should recieve the right response 'synchronously'" do
26
- stub_keen_post(api_event_resource_url(collection), 201, api_success)
29
+ stub_keen_post(api_event_resource_url(api_url, collection), 201, api_success)
27
30
  EM.synchrony {
28
31
  @client.publish_async(collection, event_properties).should == api_success
29
32
  EM.stop
@@ -33,7 +36,7 @@ describe Keen::HTTP::Async do
33
36
 
34
37
  describe "failure" do
35
38
  it "should raise an exception" do
36
- stub_request(:post, api_event_resource_url(collection)).to_timeout
39
+ stub_request(:post, api_event_resource_url(api_url, collection)).to_timeout
37
40
  e = nil
38
41
  EM.synchrony {
39
42
  begin
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.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -39,6 +39,7 @@ files:
39
39
  - .rspec
40
40
  - .travis.yml
41
41
  - Gemfile
42
+ - Gemfile.lock
42
43
  - Guardfile
43
44
  - LICENSE
44
45
  - README.md