analytics-ruby 1.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +47 -0
- data/analytics-ruby.gemspec +5 -7
- data/lib/segment.rb +1 -0
- data/lib/segment/analytics.rb +31 -0
- data/lib/segment/analytics/client.rb +335 -0
- data/lib/segment/analytics/defaults.rb +20 -0
- data/lib/segment/analytics/logging.rb +35 -0
- data/lib/segment/analytics/request.rb +80 -0
- data/lib/segment/analytics/response.rb +16 -0
- data/lib/segment/analytics/utils.rb +85 -0
- data/lib/segment/analytics/version.rb +6 -0
- data/lib/segment/analytics/worker.rb +59 -0
- data/spec/segment/analytics/client_spec.rb +248 -0
- data/spec/segment/analytics/worker_spec.rb +96 -0
- data/spec/segment/analytics_spec.rb +103 -0
- data/spec/spec_helper.rb +60 -55
- data/tags +135 -0
- metadata +34 -31
- data/analytics-ruby-0.6.0.gem +0 -0
- data/analytics-ruby-1.0.0.gem +0 -0
- data/lib/analytics-ruby.rb +0 -51
- data/lib/analytics-ruby/client.rb +0 -311
- data/lib/analytics-ruby/consumer.rb +0 -76
- data/lib/analytics-ruby/defaults.rb +0 -21
- data/lib/analytics-ruby/request.rb +0 -61
- data/lib/analytics-ruby/response.rb +0 -17
- data/lib/analytics-ruby/util.rb +0 -42
- data/lib/analytics-ruby/version.rb +0 -3
- data/spec/client_spec.rb +0 -212
- data/spec/consumer_spec.rb +0 -103
- data/spec/module_spec.rb +0 -136
data/spec/module_spec.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
require 'analytics-ruby'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe AnalyticsRuby do
|
5
|
-
|
6
|
-
describe '#not-initialized' do
|
7
|
-
it 'should ignore calls to track if not initialized' do
|
8
|
-
expect { AnalyticsRuby.track({}) }.not_to raise_error
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should return false on track if not initialized' do
|
12
|
-
AnalyticsRuby.track({}).should == false
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should ignore calls to identify if not initialized' do
|
16
|
-
expect { AnalyticsRuby.identify({}) }.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should return false on identify if not initialized' do
|
20
|
-
AnalyticsRuby.identify({}).should == false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#init' do
|
25
|
-
|
26
|
-
it 'should successfully init' do
|
27
|
-
AnalyticsRuby.init :secret => AnalyticsRubyHelpers::SECRET
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#track' do
|
32
|
-
|
33
|
-
it 'should error without an event' do
|
34
|
-
expect { AnalyticsRuby.track :user_id => 'user' }.to raise_error(ArgumentError)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should error without a user_id' do
|
38
|
-
expect { AnalyticsRuby.track :event => 'Event' }.to raise_error(ArgumentError)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should not error with the required options' do
|
42
|
-
AnalyticsRuby.track AnalyticsRubyHelpers::Queued::TRACK
|
43
|
-
sleep(1)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
describe '#identify' do
|
49
|
-
it 'should error without a user_id' do
|
50
|
-
expect { AnalyticsRuby.identify :traits => {} }.to raise_error(ArgumentError)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should not error with the required options' do
|
54
|
-
AnalyticsRuby.identify AnalyticsRubyHelpers::Queued::IDENTIFY
|
55
|
-
sleep(1)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#alias' do
|
60
|
-
it 'should error without from' do
|
61
|
-
expect { AnalyticsRuby.alias :to => 1234 }.to raise_error(ArgumentError)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should error without to' do
|
65
|
-
expect { AnalyticsRuby.alias :from => 1234 }.to raise_error(ArgumentError)
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should not error with the required options' do
|
69
|
-
AnalyticsRuby.alias AnalyticsRubyHelpers::ALIAS
|
70
|
-
sleep(1)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#group' do
|
75
|
-
it 'should error without group_id' do
|
76
|
-
expect { AnalyticsRuby.group :user_id => 'foo' }.to raise_error(ArgumentError)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should error without user_id' do
|
80
|
-
expect { AnalyticsRuby.group :group_id => 'foo' }.to raise_error(ArgumentError)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should not error with the required options' do
|
84
|
-
AnalyticsRuby.group AnalyticsRubyHelpers::Queued::GROUP
|
85
|
-
sleep(1)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '#page' do
|
90
|
-
it 'should error without user_id' do
|
91
|
-
expect { AnalyticsRuby.page :name => 'foo' }.to raise_error(ArgumentError)
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'should error without name' do
|
95
|
-
expect { AnalyticsRuby.page :user_id => 1 }.to raise_error(ArgumentError)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should not error with the required options' do
|
99
|
-
AnalyticsRuby.page AnalyticsRubyHelpers::Queued::PAGE
|
100
|
-
sleep(1)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#screen' do
|
105
|
-
it 'should error without user_id' do
|
106
|
-
expect { AnalyticsRuby.screen :name => 'foo' }.to raise_error(ArgumentError)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should error without name' do
|
110
|
-
expect { AnalyticsRuby.screen :user_id => 1 }.to raise_error(ArgumentError)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should not error with the required options' do
|
114
|
-
AnalyticsRuby.screen AnalyticsRubyHelpers::Queued::SCREEN
|
115
|
-
sleep(1)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe '#flush' do
|
120
|
-
|
121
|
-
it 'should flush without error' do
|
122
|
-
AnalyticsRuby.identify AnalyticsRubyHelpers::Queued::IDENTIFY
|
123
|
-
AnalyticsRuby.flush
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "#initialized?" do
|
128
|
-
|
129
|
-
context "when initialized" do
|
130
|
-
it "should return true" do
|
131
|
-
AnalyticsRuby.init :secret => AnalyticsRubyHelpers::SECRET
|
132
|
-
expect(AnalyticsRuby.initialized?).to be_true
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|