staccato 0.2.1 → 0.3.0

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: 3066ef529fc406e50edba8ba89871adcc483f4b4
4
- data.tar.gz: 272829dbd81ecf88bb10b132ef0b7cb0140bd0b9
3
+ metadata.gz: 77a4bb9be23d9d9cefe9806374d07466fe8720bb
4
+ data.tar.gz: 5a8c255a6a421a29bbe66552db15e16e4d2c2400
5
5
  SHA512:
6
- metadata.gz: 249bc6e61dcdea68d60cfb3dd01cc7852343667dd657bf56018d6ecb3c8fb3859bfedcae4cc589d0b9b8aed9ff1077e2e5fb54988f980e631cf30cdadaacbefc
7
- data.tar.gz: 78db6246efd0e2d0b3e1cc4a81300db05a1089e0a4a1ca489e0299d0df92f8e917fb14f80af7b1ba4cf5bff19a29435b2cf3142935854c053105080488ed30d6
6
+ metadata.gz: ca6efa1c2142f14c64ee0860bb9687d8b0fa4a8f4eb39ef3d068b031bc99ce90de0ee408c8365c355b6f8d9e6e1adcd0085e79f34a7445eb0694b55a1d4f6bdb
7
+ data.tar.gz: 4a492e972ea4776380c7ed2f041323bdffacca2c02feefab612ab96952e148a18038640c9ae2fbfbbcae3916a81851973c52a25980cbccdaf28bec90c9aa8c88
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Staccato 0.3.0 ##
2
+
3
+ * HTTP Adapters for HTTP, net/http, and Faraday
4
+
5
+ *Tony Pitale <@tpitale>*
6
+
1
7
  ## Staccato 0.2.1 ##
2
8
 
3
9
  * Fix product impression prefix
data/README.md CHANGED
@@ -414,6 +414,58 @@ https://developers.google.com/analytics/devguides/collection/protocol/v1/devguid
414
414
  https://developers.google.com/analytics/devguides/collection/protocol/v1/reference
415
415
  https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
416
416
 
417
+ ## HTTP Adapters ##
418
+
419
+ Staccato provides a number of basic adapters to different ruby http libraries. By default, Staccato uses `net/http` when you create a new tracker. If you are using Faraday or [The Ruby HTTP library](https://github.com/httprb/http.rb) Staccato provides adapters.
420
+
421
+ ```ruby
422
+ tracker = Staccato.tracker('UA-XXXX-Y') do |c|
423
+ c.adapter = Staccato::Adapter::Faraday.new(Stacatto.ga_collection_uri) do |faraday|
424
+ # further faraday configuration here
425
+ end
426
+ end
427
+ ```
428
+
429
+ You can also make your own Adapters by implementing any class that responds to `post` with a hash of params/data to be posted. The default adapters all accept the URI in the initializer, but this is not a requirement for yours.
430
+
431
+ One such example might be for a new `net/http` adapter which accepts more options for configuring the connection:
432
+
433
+ ```ruby
434
+ class CustomerAdapter
435
+ attr_reader :uri
436
+
437
+ def initialize(uri, options={})
438
+ @uri = uri
439
+ @options = options
440
+ end
441
+
442
+ def post(data)
443
+ Net::HTTP::Post.new(uri.request_uri).tap do |request|
444
+ request.read_timeout = @options.fetch(:read_timeout, 90)
445
+ request.form_data = data
446
+
447
+ execute(request)
448
+ end
449
+ end
450
+
451
+ private
452
+ def execute(request)
453
+ Net::HTTP.new(uri.hostname, uri.port).start do |http|
454
+ http.open_timeout = @options.fetch(:open_timeout, 90)
455
+ http.request(request)
456
+ end
457
+ end
458
+ end
459
+ ```
460
+
461
+ Which would be used like:
462
+
463
+ ```ruby
464
+ tracker = Staccato.tracker('UA-XXXX-Y') do |c|
465
+ c.adapter = CustomAdapter.new(Stacatto.ga_collection_uri, read_timeout: 1, open_time: 1)
466
+ end
467
+ ```
468
+
417
469
  ## Contributing ##
418
470
 
419
471
  1. Fork it
@@ -0,0 +1,18 @@
1
+ module Staccato
2
+ module Adapter
3
+ class Faraday # The Faraday Adapter
4
+ def initialize(uri)
5
+ @connection = Faraday.new(uri) do |faraday|
6
+ faraday.request :url_encoded # form-encode POST params
7
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
8
+
9
+ yield faraday if block_given?
10
+ end
11
+ end
12
+
13
+ def post(params)
14
+ @connection.post(nil, params)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module Staccato
2
+ module Adapter
3
+ class HTTP # The Ruby HTTP Library Adapter
4
+ def initialize(uri)
5
+ @uri = uri
6
+ end
7
+
8
+ def post(params)
9
+ ::HTTP.post(@uri, :form => params)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'net/http'
2
+
3
+ module Staccato
4
+ module Adapter
5
+ module Net
6
+ class HTTP # The net/http Standard Library Adapter
7
+ def initialize(uri)
8
+ @uri = uri
9
+ end
10
+
11
+ def post(params)
12
+ ::Net::HTTP.post_form(@uri, params)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,6 +4,7 @@ module Staccato
4
4
  #
5
5
  # @author Tony Pitale
6
6
  class Tracker
7
+ attr_writer :adapter
7
8
  attr_accessor :hit_defaults
8
9
 
9
10
  # sets up a new tracker
@@ -132,14 +133,22 @@ module Staccato
132
133
  # post the hit to GA collection endpoint
133
134
  # @return [Net::HTTPOK] the GA api always returns 200 OK
134
135
  def track(params={})
135
- post(Staccato.tracking_uri, params)
136
+ post(params)
136
137
  end
137
138
 
138
139
  private
139
140
 
140
141
  # @private
141
- def post(uri, params)
142
- Net::HTTP.post_form(uri, params)
142
+ def post(params)
143
+ adapter.post(params)
144
+ end
145
+
146
+ def adapter
147
+ @adapter ||= begin
148
+ require 'staccato/adapter/net_http'
149
+
150
+ Staccato::Adapter::Net::HTTP.new(Staccato.ga_collection_uri)
151
+ end
143
152
  end
144
153
  end
145
154
 
@@ -1,4 +1,4 @@
1
1
  module Staccato
2
2
  # The current Staccato VERSION
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
data/lib/staccato.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'ostruct'
2
- require 'net/http'
3
2
  require 'forwardable'
4
3
  require 'securerandom'
5
4
 
@@ -16,12 +15,14 @@ module Staccato
16
15
  # @param id [String, nil] the id provided by google, i.e., `UA-XXXXXX-Y`
17
16
  # @param client_id [String, Integer, nil] a unique id to track the session of
18
17
  # an individual user
18
+ # @params hit_options [Hash] options for use in all hits from this tracker
19
+ # @yield [Staccato::Tracker] the new tracker
19
20
  # @return [Staccato::Tracker] a new tracker is returned
20
21
  def self.tracker(id, client_id = nil, hit_options = {})
21
- if id.nil?
22
- Staccato::NoopTracker.new
23
- else
24
- Staccato::Tracker.new(id, client_id, hit_options)
22
+ klass = id.nil? ? Staccato::NoopTracker : Staccato::Tracker
23
+
24
+ klass.new(id, client_id, hit_options).tap do |tracker|
25
+ yield tracker if block_given?
25
26
  end
26
27
  end
27
28
 
@@ -33,8 +34,9 @@ module Staccato
33
34
  end
34
35
 
35
36
  # The tracking endpoint we use to submit requests to GA
36
- def self.tracking_uri
37
- URI('http://www.google-analytics.com/collect')
37
+ def self.ga_collection_uri(ssl = false)
38
+ url = (ssl ? 'https://ssl' : 'http://www') + '.google-analytics.com/collect'
39
+ URI(url)
38
40
  end
39
41
  end
40
42
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::CheckoutOption do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -30,7 +30,7 @@ describe Staccato::Measurement::CheckoutOption do
30
30
  end
31
31
 
32
32
  it 'tracks the measurment' do
33
- Net::HTTP.should have_received(:post_form).with(uri, {
33
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
34
34
  'v' => 1,
35
35
  'tid' => 'UA-XXXX-Y',
36
36
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::Checkout do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -30,7 +30,7 @@ describe Staccato::Measurement::Checkout do
30
30
  end
31
31
 
32
32
  it 'tracks the measurment' do
33
- Net::HTTP.should have_received(:post_form).with(uri, {
33
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
34
34
  'v' => 1,
35
35
  'tid' => 'UA-XXXX-Y',
36
36
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::ProductImpression do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -39,7 +39,7 @@ describe Staccato::Measurement::ProductImpression do
39
39
  end
40
40
 
41
41
  it 'tracks the measurment' do
42
- Net::HTTP.should have_received(:post_form).with(uri, {
42
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
43
43
  'v' => 1,
44
44
  'tid' => 'UA-XXXX-Y',
45
45
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::Product do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -41,7 +41,7 @@ describe Staccato::Measurement::Product do
41
41
  end
42
42
 
43
43
  it 'tracks the measurment' do
44
- Net::HTTP.should have_received(:post_form).with(uri, {
44
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
45
45
  'v' => 1,
46
46
  'tid' => 'UA-XXXX-Y',
47
47
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::Promotion do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -33,7 +33,7 @@ describe Staccato::Measurement::Promotion do
33
33
  end
34
34
 
35
35
  it 'tracks the measurment' do
36
- Net::HTTP.should have_received(:post_form).with(uri, {
36
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
37
37
  'v' => 1,
38
38
  'tid' => 'UA-XXXX-Y',
39
39
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Measurement::Transaction do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -35,7 +35,7 @@ describe Staccato::Measurement::Transaction do
35
35
  end
36
36
 
37
37
  it 'tracks the measurment' do
38
- Net::HTTP.should have_received(:post_form).with(uri, {
38
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
39
39
  'v' => 1,
40
40
  'tid' => 'UA-XXXX-Y',
41
41
  'cid' => '555',
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::NoopTracker do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker(nil)}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -16,7 +16,7 @@ describe Staccato::NoopTracker do
16
16
  end
17
17
 
18
18
  it 'does not track page path and page title' do
19
- Net::HTTP.should have_received(:post_form).never
19
+ expect(Net::HTTP).to have_received(:post_form).never
20
20
  end
21
21
  end
22
22
 
@@ -31,7 +31,7 @@ describe Staccato::NoopTracker do
31
31
  end
32
32
 
33
33
  it 'does not track event category, action, label, value' do
34
- Net::HTTP.should have_received(:post_form).never
34
+ expect(Net::HTTP).to have_received(:post_form).never
35
35
  end
36
36
  end
37
37
 
@@ -45,7 +45,7 @@ describe Staccato::NoopTracker do
45
45
  end
46
46
 
47
47
  it 'does not track social action, network, target' do
48
- Net::HTTP.should have_received(:post_form).never
48
+ expect(Net::HTTP).to have_received(:post_form).never
49
49
  end
50
50
  end
51
51
 
@@ -58,7 +58,7 @@ describe Staccato::NoopTracker do
58
58
  end
59
59
 
60
60
  it 'does not track exception description and fatality' do
61
- Net::HTTP.should have_received(:post_form).never
61
+ expect(Net::HTTP).to have_received(:post_form).never
62
62
  end
63
63
  end
64
64
 
@@ -73,7 +73,7 @@ describe Staccato::NoopTracker do
73
73
  end
74
74
 
75
75
  it 'does not track user timing category, variable, label, and time' do
76
- Net::HTTP.should have_received(:post_form).never
76
+ expect(Net::HTTP).to have_received(:post_form).never
77
77
  end
78
78
  end
79
79
 
@@ -92,11 +92,11 @@ describe Staccato::NoopTracker do
92
92
  end
93
93
 
94
94
  it 'does not track user timing category, variable, label, and time' do
95
- Net::HTTP.should have_received(:post_form).never
95
+ expect(Net::HTTP).to have_received(:post_form).never
96
96
  end
97
97
 
98
98
  it 'yields to the block' do
99
- codez.should have_received(:test)
99
+ expect(codez).to have_received(:test)
100
100
  end
101
101
  end
102
102
 
@@ -106,7 +106,7 @@ describe Staccato::NoopTracker do
106
106
  end
107
107
 
108
108
  it 'does not send a post request' do
109
- Net::HTTP.should have_received(:post_form).never
109
+ expect(Net::HTTP).to have_received(:post_form).never
110
110
  end
111
111
  end
112
112
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Staccato::Tracker do
4
- let(:uri) {Staccato.tracking_uri}
4
+ let(:uri) {Staccato.ga_collection_uri}
5
5
  let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
6
  let(:response) {stub(:body => '', :status => 201)}
7
7
 
@@ -16,7 +16,7 @@ describe Staccato::Tracker do
16
16
  end
17
17
 
18
18
  it 'tracks page path and page title' do
19
- Net::HTTP.should have_received(:post_form).with(uri, {
19
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
20
20
  'v' => 1,
21
21
  'tid' => 'UA-XXXX-Y',
22
22
  'cid' => '555',
@@ -39,7 +39,7 @@ describe Staccato::Tracker do
39
39
  end
40
40
 
41
41
  it 'tracks event category, action, label, value' do
42
- Net::HTTP.should have_received(:post_form).with(uri, {
42
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
43
43
  'v' => 1,
44
44
  'tid' => 'UA-XXXX-Y',
45
45
  'cid' => '555',
@@ -62,7 +62,7 @@ describe Staccato::Tracker do
62
62
  end
63
63
 
64
64
  it 'tracks social action, network, target' do
65
- Net::HTTP.should have_received(:post_form).with(uri, {
65
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
66
66
  'v' => 1,
67
67
  'tid' => 'UA-XXXX-Y',
68
68
  'cid' => '555',
@@ -84,7 +84,7 @@ describe Staccato::Tracker do
84
84
  end
85
85
 
86
86
  it 'tracks exception description and fatality' do
87
- Net::HTTP.should have_received(:post_form).with(uri, {
87
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
88
88
  'v' => 1,
89
89
  'tid' => 'UA-XXXX-Y',
90
90
  'cid' => '555',
@@ -107,7 +107,7 @@ describe Staccato::Tracker do
107
107
  end
108
108
 
109
109
  it 'tracks user timing category, variable, label, and time' do
110
- Net::HTTP.should have_received(:post_form).with(uri, {
110
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
111
111
  'v' => 1,
112
112
  'tid' => 'UA-XXXX-Y',
113
113
  'cid' => '555',
@@ -135,7 +135,7 @@ describe Staccato::Tracker do
135
135
  end
136
136
 
137
137
  it 'tracks user timing category, variable, label, and time' do
138
- Net::HTTP.should have_received(:post_form).with(uri, {
138
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
139
139
  'v' => 1,
140
140
  'tid' => 'UA-XXXX-Y',
141
141
  'cid' => '555',
@@ -148,7 +148,7 @@ describe Staccato::Tracker do
148
148
  end
149
149
 
150
150
  it 'yields to the block' do
151
- codez.should have_received(:test)
151
+ expect(codez).to have_received(:test)
152
152
  end
153
153
  end
154
154
 
@@ -168,7 +168,7 @@ describe Staccato::Tracker do
168
168
  end
169
169
 
170
170
  it 'tracks the transaction values' do
171
- Net::HTTP.should have_received(:post_form).with(uri, {
171
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
172
172
  'v' => 1,
173
173
  'tid' => 'UA-XXXX-Y',
174
174
  'cid' => '555',
@@ -199,7 +199,7 @@ describe Staccato::Tracker do
199
199
  end
200
200
 
201
201
  it 'tracks the item values' do
202
- Net::HTTP.should have_received(:post_form).with(uri, {
202
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
203
203
  'v' => 1,
204
204
  'tid' => 'UA-XXXX-Y',
205
205
  'cid' => '555',
@@ -224,7 +224,7 @@ describe Staccato::Tracker do
224
224
  it 'tracks page path and default hostname' do
225
225
  tracker.pageview(path: '/foobar')
226
226
 
227
- Net::HTTP.should have_received(:post_form).with(uri, {
227
+ expect(Net::HTTP).to have_received(:post_form).with(uri, {
228
228
  'v' => 1,
229
229
  'tid' => 'UA-XXXX-Y',
230
230
  'cid' => '555',
@@ -7,13 +7,13 @@ describe Staccato do
7
7
  let(:tracker) {Staccato.tracker 'UA-XXXX-Y'}
8
8
 
9
9
  it 'has an assigned id' do
10
- tracker.id.should eq('UA-XXXX-Y')
10
+ expect(tracker.id).to eq('UA-XXXX-Y')
11
11
  end
12
12
 
13
13
  it 'uses a uuid for the client_id' do
14
14
  SecureRandom.stubs(:uuid).returns("a-uuid")
15
15
 
16
- tracker.client_id.should eq('a-uuid')
16
+ expect(tracker.client_id).to eq('a-uuid')
17
17
  end
18
18
 
19
19
  end
@@ -15,23 +15,23 @@ describe Staccato::Event do
15
15
  end
16
16
 
17
17
  it 'has a category' do
18
- event.category.should eq('video')
18
+ expect(event.category).to eq('video')
19
19
  end
20
20
 
21
21
  it 'has a action' do
22
- event.action.should eq('play')
22
+ expect(event.action).to eq('play')
23
23
  end
24
24
 
25
25
  it 'has a label' do
26
- event.label.should eq('cars')
26
+ expect(event.label).to eq('cars')
27
27
  end
28
28
 
29
29
  it 'has a value' do
30
- event.value.should eq(12)
30
+ expect(event.value).to eq(12)
31
31
  end
32
32
 
33
33
  it 'has all params' do
34
- event.params.should eq({
34
+ expect(event.params).to eq({
35
35
  'v' => 1,
36
36
  'tid' => 'UA-XXXX-Y',
37
37
  'cid' => '555',
@@ -57,7 +57,7 @@ describe Staccato::Event do
57
57
  end
58
58
 
59
59
  it 'has all params' do
60
- event.params.should eq({
60
+ expect(event.params).to eq({
61
61
  'v' => 1,
62
62
  'tid' => 'UA-XXXX-Y',
63
63
  'cid' => '555',
@@ -76,7 +76,7 @@ describe Staccato::Event do
76
76
  end
77
77
 
78
78
  it 'has require params' do
79
- event.params.should eq({
79
+ expect(event.params).to eq({
80
80
  'v' => 1,
81
81
  'tid' => 'UA-XXXX-Y',
82
82
  'cid' => '555',
@@ -14,19 +14,19 @@ describe Staccato::Pageview do
14
14
  end
15
15
 
16
16
  it 'has a hostname' do
17
- pageview.hostname.should eq('mysite.com')
17
+ expect(pageview.hostname).to eq('mysite.com')
18
18
  end
19
19
 
20
20
  it 'has a path' do
21
- pageview.path.should eq('/foobar')
21
+ expect(pageview.path).to eq('/foobar')
22
22
  end
23
23
 
24
24
  it 'has a title' do
25
- pageview.title.should eq('FooBar')
25
+ expect(pageview.title).to eq('FooBar')
26
26
  end
27
27
 
28
28
  it 'has all params' do
29
- pageview.params.should eq({
29
+ expect(pageview.params).to eq({
30
30
  'v' => 1,
31
31
  'tid' => 'UA-XXXX-Y',
32
32
  'cid' => '555',
@@ -49,7 +49,7 @@ describe Staccato::Pageview do
49
49
  end
50
50
 
51
51
  it 'has all params' do
52
- pageview.params.should eq({
52
+ expect(pageview.params).to eq({
53
53
  'v' => 1,
54
54
  'tid' => 'UA-XXXX-Y',
55
55
  'cid' => '555',
@@ -67,7 +67,7 @@ describe Staccato::Pageview do
67
67
  end
68
68
 
69
69
  it 'has required params' do
70
- pageview.params.should eq({
70
+ expect(pageview.params).to eq({
71
71
  'v' => 1,
72
72
  'tid' => 'UA-XXXX-Y',
73
73
  'cid' => '555',
@@ -85,7 +85,7 @@ describe Staccato::Pageview do
85
85
  end
86
86
 
87
87
  it 'has experiment id and variant' do
88
- pageview.params.should eq({
88
+ expect(pageview.params).to eq({
89
89
  'v' => 1,
90
90
  'tid' => 'UA-XXXX-Y',
91
91
  'cid' => '555',
@@ -104,7 +104,7 @@ describe Staccato::Pageview do
104
104
  end
105
105
 
106
106
  it 'has session control param' do
107
- pageview.params.should eq({
107
+ expect(pageview.params).to eq({
108
108
  'v' => 1,
109
109
  'tid' => 'UA-XXXX-Y',
110
110
  'cid' => '555',
@@ -125,7 +125,7 @@ describe Staccato::Pageview do
125
125
  end
126
126
 
127
127
  it 'has custom dimensions' do
128
- pageview.params.should eq({
128
+ expect(pageview.params).to eq({
129
129
  'v' => 1,
130
130
  'tid' => 'UA-XXXX-Y',
131
131
  'cid' => '555',
@@ -147,7 +147,7 @@ describe Staccato::Pageview do
147
147
  end
148
148
 
149
149
  it 'has custom dimensions' do
150
- pageview.params.should eq({
150
+ expect(pageview.params).to eq({
151
151
  'v' => 1,
152
152
  'tid' => 'UA-XXXX-Y',
153
153
  'cid' => '555',
@@ -15,11 +15,11 @@ describe Staccato::Tracker do
15
15
  end
16
16
 
17
17
  it "creates a new Pageview" do
18
- Staccato::Pageview.should have_received(:new).with(tracker, path: '/foobar')
18
+ expect(Staccato::Pageview).to have_received(:new).with(tracker, path: '/foobar')
19
19
  end
20
20
 
21
21
  it "tracks on the Pageview" do
22
- pageview.should have_received(:track!)
22
+ expect(pageview).to have_received(:track!)
23
23
  end
24
24
  end
25
25
 
@@ -34,11 +34,11 @@ describe Staccato::Tracker do
34
34
  end
35
35
 
36
36
  it "creates a new Event" do
37
- Staccato::Event.should have_received(:new).with(tracker, category: 'video', action: 'play')
37
+ expect(Staccato::Event).to have_received(:new).with(tracker, category: 'video', action: 'play')
38
38
  end
39
39
 
40
40
  it "tracks on the Event" do
41
- event.should have_received(:track!)
41
+ expect(event).to have_received(:track!)
42
42
  end
43
43
  end
44
44
 
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,6 @@ require File.expand_path('../../lib/staccato', __FILE__)
13
13
  RSpec.configure do |config|
14
14
  config.mock_with :mocha
15
15
 
16
- config.treat_symbols_as_metadata_keys_with_true_values = true
17
16
  config.run_all_when_everything_filtered = true
18
17
  config.filter_run :focus
19
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staccato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-14 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,6 +111,9 @@ files:
111
111
  - README.md
112
112
  - Rakefile
113
113
  - lib/staccato.rb
114
+ - lib/staccato/adapter/faraday.rb
115
+ - lib/staccato/adapter/http.rb
116
+ - lib/staccato/adapter/net_http.rb
114
117
  - lib/staccato/boolean_helpers.rb
115
118
  - lib/staccato/event.rb
116
119
  - lib/staccato/exception.rb
@@ -191,3 +194,4 @@ test_files:
191
194
  - spec/lib/staccato/pageview_spec.rb
192
195
  - spec/lib/staccato/tracker_spec.rb
193
196
  - spec/spec_helper.rb
197
+ has_rdoc: