analytics-ruby 2.2.5 → 2.4.0

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.
data/spec/spec_helper.rb DELETED
@@ -1,128 +0,0 @@
1
- # https://github.com/codecov/codecov-ruby#usage
2
- require 'simplecov'
3
- SimpleCov.start
4
- require 'codecov'
5
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
6
-
7
- require 'segment/analytics'
8
- require 'active_support/time'
9
- require './spec/helpers/runscope_client'
10
-
11
- # Setting timezone for ActiveSupport::TimeWithZone to UTC
12
- Time.zone = 'UTC'
13
-
14
- module Segment
15
- class Analytics
16
- WRITE_KEY = 'testsecret'
17
-
18
- TRACK = {
19
- :event => 'Ruby Library test event',
20
- :properties => {
21
- :type => 'Chocolate',
22
- :is_a_lie => true,
23
- :layers => 20,
24
- :created => Time.new
25
- }
26
- }
27
-
28
- IDENTIFY = {
29
- :traits => {
30
- :likes_animals => true,
31
- :instrument => 'Guitar',
32
- :age => 25
33
- }
34
- }
35
-
36
- ALIAS = {
37
- :previous_id => 1234,
38
- :user_id => 'abcd'
39
- }
40
-
41
- GROUP = {}
42
-
43
- PAGE = {
44
- :name => 'home'
45
- }
46
-
47
- SCREEN = {
48
- :name => 'main'
49
- }
50
-
51
- USER_ID = 1234
52
- GROUP_ID = 1234
53
-
54
- # Hashes sent to the client, snake_case
55
- module Queued
56
- TRACK = TRACK.merge :user_id => USER_ID
57
- IDENTIFY = IDENTIFY.merge :user_id => USER_ID
58
- GROUP = GROUP.merge :group_id => GROUP_ID, :user_id => USER_ID
59
- PAGE = PAGE.merge :user_id => USER_ID
60
- SCREEN = SCREEN.merge :user_id => USER_ID
61
- end
62
-
63
- # Hashes which are sent from the worker, camel_cased
64
- module Requested
65
- TRACK = TRACK.merge({
66
- :userId => USER_ID,
67
- :type => 'track'
68
- })
69
-
70
- IDENTIFY = IDENTIFY.merge({
71
- :userId => USER_ID,
72
- :type => 'identify'
73
- })
74
-
75
- GROUP = GROUP.merge({
76
- :groupId => GROUP_ID,
77
- :userId => USER_ID,
78
- :type => 'group'
79
- })
80
-
81
- PAGE = PAGE.merge :userId => USER_ID
82
- SCREEN = SCREEN.merge :userId => USER_ID
83
- end
84
- end
85
- end
86
-
87
- # A worker that doesn't consume jobs
88
- class NoopWorker
89
- def run
90
- # Does nothing
91
- end
92
- end
93
-
94
- # A backoff policy that returns a fixed list of values
95
- class FakeBackoffPolicy
96
- def initialize(interval_values)
97
- @interval_values = interval_values
98
- end
99
-
100
- def next_interval
101
- raise 'FakeBackoffPolicy has no values left' if @interval_values.empty?
102
- @interval_values.shift
103
- end
104
- end
105
-
106
- # usage:
107
- # it "should return a result of 5" do
108
- # eventually(options: {timeout: 1}) { long_running_thing.result.should eq(5) }
109
- # end
110
-
111
- module AsyncHelper
112
- def eventually(options = {})
113
- timeout = options[:timeout] || 2
114
- interval = options[:interval] || 0.1
115
- time_limit = Time.now + timeout
116
- loop do
117
- begin
118
- yield
119
- return
120
- rescue RSpec::Expectations::ExpectationNotMetError => error
121
- raise error if Time.now >= time_limit
122
- sleep interval
123
- end
124
- end
125
- end
126
- end
127
-
128
- include AsyncHelper