vero 0.9.1 → 0.10.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -1
  3. data/Gemfile.lock +95 -73
  4. data/README.markdown +145 -121
  5. data/lib/generators/vero_generator.rb +18 -19
  6. data/lib/vero.rb +7 -3
  7. data/lib/vero/api.rb +14 -4
  8. data/lib/vero/api/base_api.rb +11 -10
  9. data/lib/vero/api/events/track_api.rb +5 -3
  10. data/lib/vero/api/users/delete_api.rb +21 -0
  11. data/lib/vero/api/users/edit_api.rb +5 -3
  12. data/lib/vero/api/users/edit_tags_api.rb +7 -5
  13. data/lib/vero/api/users/reidentify_api.rb +5 -3
  14. data/lib/vero/api/users/resubscribe_api.rb +3 -1
  15. data/lib/vero/api/users/track_api.rb +5 -3
  16. data/lib/vero/api/users/unsubscribe_api.rb +3 -1
  17. data/lib/vero/app.rb +4 -2
  18. data/lib/vero/config.rb +11 -8
  19. data/lib/vero/context.rb +9 -11
  20. data/lib/vero/context/api.rb +9 -7
  21. data/lib/vero/dsl.rb +3 -1
  22. data/lib/vero/railtie.rb +5 -3
  23. data/lib/vero/sender.rb +12 -31
  24. data/lib/vero/senders/base.rb +3 -1
  25. data/lib/vero/senders/delayed_job.rb +7 -7
  26. data/lib/vero/senders/invalid.rb +5 -3
  27. data/lib/vero/senders/resque.rb +8 -8
  28. data/lib/vero/senders/sidekiq.rb +3 -1
  29. data/lib/vero/senders/{thread.rb → sucker_punch.rb} +5 -3
  30. data/lib/vero/trackable.rb +4 -2
  31. data/lib/vero/trackable/base.rb +10 -9
  32. data/lib/vero/trackable/interface.rb +3 -1
  33. data/lib/vero/utility/ext.rb +3 -1
  34. data/lib/vero/utility/logger.rb +4 -6
  35. data/lib/vero/version.rb +3 -1
  36. data/lib/vero/view_helpers/javascript.rb +20 -20
  37. data/spec/lib/api/base_api_spec.rb +10 -8
  38. data/spec/lib/api/events/track_api_spec.rb +23 -21
  39. data/spec/lib/api/users/delete_api_spec.rb +33 -0
  40. data/spec/lib/api/users/edit_api_spec.rb +12 -10
  41. data/spec/lib/api/users/edit_tags_api_spec.rb +22 -20
  42. data/spec/lib/api/users/reidentify_spec.rb +16 -14
  43. data/spec/lib/api/users/resubscribe_api_spec.rb +16 -10
  44. data/spec/lib/api/users/track_api_spec.rb +21 -19
  45. data/spec/lib/api/users/unsubscribe_api_spec.rb +12 -10
  46. data/spec/lib/api_spec.rb +29 -24
  47. data/spec/lib/app_spec.rb +12 -10
  48. data/spec/lib/config_spec.rb +31 -29
  49. data/spec/lib/context_spec.rb +13 -11
  50. data/spec/lib/dsl_spec.rb +3 -1
  51. data/spec/lib/sender_spec.rb +12 -24
  52. data/spec/lib/senders/sidekiq_spec.rb +16 -9
  53. data/spec/lib/trackable_spec.rb +88 -114
  54. data/spec/lib/view_helpers_spec.rb +12 -8
  55. data/spec/spec_helper.rb +10 -4
  56. data/spec/support/base_config_shared_examples.rb +5 -3
  57. data/spec/support/user_support.rb +15 -7
  58. data/spec/support/vero_user_support.rb +4 -2
  59. data/vero.gemspec +14 -30
  60. metadata +30 -125
@@ -1,11 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Vero::Senders::Sidekiq do
4
6
  subject { Vero::Senders::Sidekiq.new }
5
7
  describe :call do
6
- it "should perform_async a Vero::SidekiqWorker" do
7
- Vero::SidekiqWorker.should_receive(:perform_async).with('Vero::Api::Workers::Events::TrackAPI', "abc", {:test => "abc"}).once
8
- subject.call(Vero::Api::Workers::Events::TrackAPI, "abc", {:test => "abc"})
8
+ it 'should perform_async a Vero::SidekiqWorker' do
9
+ expect(Vero::SidekiqWorker).to(
10
+ receive(:perform_async)
11
+ .with('Vero::Api::Workers::Events::TrackAPI', 'abc', { test: 'abc' })
12
+ .once
13
+ )
14
+ subject.call(Vero::Api::Workers::Events::TrackAPI, 'abc', { test: 'abc' })
9
15
  end
10
16
  end
11
17
  end
@@ -13,13 +19,14 @@ end
13
19
  describe Vero::SidekiqWorker do
14
20
  subject { Vero::SidekiqWorker.new }
15
21
  describe :perform do
16
- it "should call the api method" do
22
+ it 'should call the api method' do
17
23
  mock_api = double(Vero::Api::Workers::Events::TrackAPI)
18
- mock_api.should_receive(:perform).once
19
- Vero::Api::Workers::Events::TrackAPI.stub(:new).and_return(mock_api)
20
- Vero::Api::Workers::Events::TrackAPI.should_receive(:new).with("abc", {:test => "abc"}).once
24
+ expect(mock_api).to receive(:perform).once
25
+
26
+ allow(Vero::Api::Workers::Events::TrackAPI).to receive(:new).and_return(mock_api)
27
+ expect(Vero::Api::Workers::Events::TrackAPI).to receive(:new).with('abc', { test: 'abc' }).once
21
28
 
22
- subject.perform('Vero::Api::Workers::Events::TrackAPI', "abc", {:test => "abc"})
29
+ subject.perform('Vero::Api::Workers::Events::TrackAPI', 'abc', { test: 'abc' })
23
30
  end
24
31
  end
25
- end
32
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  def vero_context(user, logging = true, async = false, disabled = true)
@@ -13,21 +15,21 @@ end
13
15
  describe Vero::Trackable do
14
16
  before :each do
15
17
  @request_params = {
16
- :event_name => 'test_event',
17
- :auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
18
- :identity => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"},
19
- :data => {:test => 1},
20
- :development_mode => true
18
+ event_name: 'test_event',
19
+ auth_token: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
20
+ identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' },
21
+ data: { test: 1 },
22
+ development_mode: true
21
23
  }
22
- @url = "https://api.getvero.com/api/v1/track.json"
24
+ @url = 'https://api.getvero.com/api/v1/track.json'
23
25
  @user = User.new
24
26
 
25
- @content_type_params = {:content_type => :json, :accept => :json}
27
+ @content_type_params = { content_type: :json, accept: :json }
26
28
  end
27
29
 
28
- context "the gem has not been configured" do
30
+ context 'the gem has not been configured' do
29
31
  before { Vero::App.reset! }
30
- it "should raise an error when API requests are made" do
32
+ it 'should raise an error when API requests are made' do
31
33
  expect { @user.track(@request_params[:event_name], @request_params[:data]) }.to raise_error(RuntimeError)
32
34
 
33
35
  allow(@user).to receive(:post_later).and_return('success')
@@ -35,7 +37,7 @@ describe Vero::Trackable do
35
37
  end
36
38
  end
37
39
 
38
- context "the gem has been configured" do
40
+ context 'the gem has been configured' do
39
41
  before do
40
42
  Vero::App.init do |c|
41
43
  c.api_key = 'abcd1234'
@@ -47,21 +49,21 @@ describe Vero::Trackable do
47
49
  describe :track! do
48
50
  before do
49
51
  @request_params = {
50
- :event_name => 'test_event',
51
- :identity => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"},
52
- :data => { :test => 1 },
53
- :extras => {}
52
+ event_name: 'test_event',
53
+ identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' },
54
+ data: { test: 1 },
55
+ extras: {}
54
56
  }
55
- @url = "https://api.getvero.com/api/v1/track.json"
57
+ @url = 'https://api.getvero.com/api/v1/track.json'
56
58
  end
57
59
 
58
- it "should not send a track request when the required parameters are invalid" do
60
+ it 'should not send a track request when the required parameters are invalid' do
59
61
  expect { @user.track!(nil) }.to raise_error(ArgumentError)
60
62
  expect { @user.track!('') }.to raise_error(ArgumentError)
61
63
  expect { @user.track!('test', '') }.to raise_error(ArgumentError)
62
64
  end
63
65
 
64
- it "should send a `track!` request when async is set to false" do
66
+ it 'should send a `track!` request when async is set to false' do
65
67
  context = vero_context(@user)
66
68
  allow(@user).to receive(:with_vero_context).and_return(context)
67
69
 
@@ -72,7 +74,7 @@ describe Vero::Trackable do
72
74
  expect(@user.track!(@request_params[:event_name], @request_params[:data])).to eq(200)
73
75
 
74
76
  allow(Vero::Api::Events).to receive(:track!).and_return(200)
75
- expect(Vero::Api::Events).to receive(:track!).with(@request_params.merge(:data => {}), context)
77
+ expect(Vero::Api::Events).to receive(:track!).with(@request_params.merge(data: {}), context)
76
78
  expect(@user.track!(@request_params[:event_name])).to eq(200)
77
79
  end
78
80
 
@@ -82,13 +84,9 @@ describe Vero::Trackable do
82
84
  allow(@user).to receive(:with_vero_context).and_return(@context)
83
85
  end
84
86
 
85
- context 'not using Ruby 1.8.7' do
86
- before { stub_const('RUBY_VERSION', '1.9.3') }
87
-
88
- it 'sends' do
89
- expect(@user.track!(@request_params[:event_name], @request_params[:data])).to be_nil
90
- expect(@user.track!(@request_params[:event_name])).to be_nil
91
- end
87
+ it 'sends' do
88
+ expect(@user.track!(@request_params[:event_name], @request_params[:data])).to be_nil
89
+ expect(@user.track!(@request_params[:event_name])).to be_nil
92
90
  end
93
91
  end
94
92
  end
@@ -96,14 +94,14 @@ describe Vero::Trackable do
96
94
  describe :identify! do
97
95
  before do
98
96
  @request_params = {
99
- :id => nil,
100
- :email => 'durkster@gmail.com',
101
- :data => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"}
97
+ id: nil,
98
+ email: 'durkster@gmail.com',
99
+ data: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' }
102
100
  }
103
- @url = "https://api.getvero.com/api/v2/users/track.json"
101
+ @url = 'https://api.getvero.com/api/v2/users/track.json'
104
102
  end
105
103
 
106
- it "should send an `identify` request when async is set to false" do
104
+ it 'should send an `identify` request when async is set to false' do
107
105
  context = vero_context(@user)
108
106
  allow(@user).to receive(:with_vero_context).and_return(context)
109
107
 
@@ -119,12 +117,8 @@ describe Vero::Trackable do
119
117
  allow(@user).to receive(:with_vero_context).and_return(@context)
120
118
  end
121
119
 
122
- context 'and not using Ruby 1.8.7' do
123
- before { stub_const('RUBY_VERSION', '1.9.3') }
124
-
125
- it 'sends' do
126
- expect(@user.identify!).to be_nil
127
- end
120
+ it 'sends' do
121
+ expect(@user.identify!).to be_nil
128
122
  end
129
123
  end
130
124
  end
@@ -132,14 +126,14 @@ describe Vero::Trackable do
132
126
  describe :update_user! do
133
127
  before do
134
128
  @request_params = {
135
- :id => nil,
136
- :email => 'durkster@gmail.com',
137
- :changes => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"},
129
+ id: nil,
130
+ email: 'durkster@gmail.com',
131
+ changes: { email: 'durkster@gmail.com', age: 20, _user_type: 'User' }
138
132
  }
139
- @url = "https://api.getvero.com/api/v2/users/edit.json"
133
+ @url = 'https://api.getvero.com/api/v2/users/edit.json'
140
134
  end
141
135
 
142
- it "should send an `update_user` request when async is set to false" do
136
+ it 'should send an `update_user` request when async is set to false' do
143
137
  context = Vero::Context.new(Vero::App.default_context)
144
138
  context.subject = @user
145
139
 
@@ -157,21 +151,8 @@ describe Vero::Trackable do
157
151
  allow(@user).to receive(:with_vero_context).and_return(@context)
158
152
  end
159
153
 
160
- context 'and using Ruby 1.8.7' do
161
- before { stub_const('RUBY_VERSION', '1.8.7') }
162
-
163
- it 'raises an error' do
164
- @context.config.disabled = false
165
- expect { @user.with_vero_context.update_user! }.to raise_error(RuntimeError)
166
- end
167
- end
168
-
169
- context 'and not using Ruby 1.8.7' do
170
- before { stub_const('RUBY_VERSION', '1.9.3') }
171
-
172
- it 'sends' do
173
- expect(@user.with_vero_context.update_user!).to be_nil
174
- end
154
+ it 'sends' do
155
+ expect(@user.with_vero_context.update_user!).to be_nil
175
156
  end
176
157
  end
177
158
  end
@@ -179,15 +160,15 @@ describe Vero::Trackable do
179
160
  describe :update_user_tags! do
180
161
  before do
181
162
  @request_params = {
182
- :id => nil,
183
- :email => 'durkster@gmail.com',
184
- :add => [],
185
- :remove => []
163
+ id: nil,
164
+ email: 'durkster@gmail.com',
165
+ add: [],
166
+ remove: []
186
167
  }
187
- @url = "https://api.getvero.com/api/v2/users/tags/edit.json"
168
+ @url = 'https://api.getvero.com/api/v2/users/tags/edit.json'
188
169
  end
189
170
 
190
- it "should send an `update_user_tags` request when async is set to false" do
171
+ it 'should send an `update_user_tags` request when async is set to false' do
191
172
  context = Vero::Context.new(Vero::App.default_context)
192
173
  context.subject = @user
193
174
  context.config.async = false
@@ -200,29 +181,27 @@ describe Vero::Trackable do
200
181
  expect(@user.with_vero_context.update_user_tags!).to eq(200)
201
182
  end
202
183
 
203
- if RUBY_VERSION =~ /1\.9\./
204
- it "should send using another thread when async is set to true" do
205
- context = Vero::Context.new(Vero::App.default_context)
206
- context.subject = @user
207
- context.config.async = true
184
+ it 'should send using another thread when async is set to true' do
185
+ context = Vero::Context.new(Vero::App.default_context)
186
+ context.subject = @user
187
+ context.config.async = true
208
188
 
209
- allow(@user).to receive(:with_vero_context).and_return(context)
189
+ allow(@user).to receive(:with_vero_context).and_return(context)
210
190
 
211
- expect(@user.with_vero_context.update_user_tags!).to be_nil
212
- end
191
+ expect(@user.with_vero_context.update_user_tags!).to be_nil
213
192
  end
214
193
  end
215
194
 
216
195
  describe :unsubscribe! do
217
196
  before do
218
197
  @request_params = {
219
- :id => nil,
220
- :email => 'durkster@gmail.com'
198
+ id: nil,
199
+ email: 'durkster@gmail.com'
221
200
  }
222
- @url = "https://api.getvero.com/api/v2/users/unsubscribe.json"
201
+ @url = 'https://api.getvero.com/api/v2/users/unsubscribe.json'
223
202
  end
224
203
 
225
- it "should send an `update_user` request when async is set to false" do
204
+ it 'should send an `update_user` request when async is set to false' do
226
205
  context = Vero::Context.new(Vero::App.default_context)
227
206
  context.subject = @user
228
207
  context.config.async = false
@@ -241,12 +220,8 @@ describe Vero::Trackable do
241
220
  allow(@user).to receive(:with_vero_context).and_return(@context)
242
221
  end
243
222
 
244
- context 'and using Ruby 1.9.3' do
245
- before { stub_const('RUBY_VERSION', '1.9.3') }
246
-
247
- it 'sends' do
248
- expect(@user.with_vero_context.unsubscribe!).to be_nil
249
- end
223
+ it 'sends' do
224
+ expect(@user.with_vero_context.unsubscribe!).to be_nil
250
225
  end
251
226
  end
252
227
  end
@@ -254,20 +229,20 @@ describe Vero::Trackable do
254
229
  describe :trackable do
255
230
  before { User.reset_trackable_map! }
256
231
 
257
- it "should build an array of trackable params" do
232
+ it 'should build an array of trackable params' do
258
233
  User.trackable :email, :age
259
- expect(User.trackable_map).to eq([:email, :age])
234
+ expect(User.trackable_map).to eq(%i[email age])
260
235
  end
261
236
 
262
- it "should append new trackable items to an existing trackable map" do
237
+ it 'should append new trackable items to an existing trackable map' do
263
238
  User.trackable :email, :age
264
239
  User.trackable :hair_colour
265
- expect(User.trackable_map).to eq([:email, :age, :hair_colour])
240
+ expect(User.trackable_map).to eq(%i[email age hair_colour])
266
241
  end
267
242
 
268
243
  it "should append an extra's hash to the trackable map" do
269
- User.trackable :email, {:extras => :properties}
270
- expect(User.trackable_map).to eq([:email, {:extras => :properties}])
244
+ User.trackable :email, { extras: :properties }
245
+ expect(User.trackable_map).to eq([:email, { extras: :properties }])
271
246
  end
272
247
  end
273
248
 
@@ -277,70 +252,69 @@ describe Vero::Trackable do
277
252
  User.trackable :email, :age
278
253
  end
279
254
 
280
- it "should return a hash of all values mapped by trackable" do
255
+ it 'should return a hash of all values mapped by trackable' do
281
256
  user = User.new
282
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"})
257
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'User' })
283
258
 
284
259
  user = UserWithoutEmail.new
285
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 20, :_user_type => "UserWithoutEmail"})
260
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutEmail' })
286
261
 
287
262
  user = UserWithEmailAddress.new
288
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 20, :_user_type => "UserWithEmailAddress"})
263
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithEmailAddress' })
289
264
 
290
265
  user = UserWithoutInterface.new
291
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 20, :_user_type => "UserWithoutInterface"})
266
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutInterface' })
292
267
 
293
268
  user = UserWithNilAttributes.new
294
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :_user_type => "UserWithNilAttributes"})
269
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithNilAttributes' })
295
270
  end
296
271
 
297
- it "should take into account any defined extras" do
272
+ it 'should take into account any defined extras' do
298
273
  user = UserWithExtras.new
299
274
  user.properties = nil
300
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :_user_type => "UserWithExtras"})
275
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
301
276
 
302
- user.properties = "test"
303
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :_user_type => "UserWithExtras"})
277
+ user.properties = 'test'
278
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
304
279
 
305
280
  user.properties = {}
306
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :_user_type => "UserWithExtras"})
281
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithExtras' })
307
282
 
308
283
  user.properties = {
309
- :age => 20,
310
- :gender => "female"
284
+ age: 20,
285
+ gender: 'female'
311
286
  }
312
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 20, :gender => "female", :_user_type => "UserWithExtras"})
287
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 20, gender: 'female', _user_type: 'UserWithExtras' })
313
288
 
314
289
  user = UserWithPrivateExtras.new
315
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :age => 26, :_user_type => "UserWithPrivateExtras"})
290
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', age: 26, _user_type: 'UserWithPrivateExtras' })
316
291
  end
317
292
 
318
- it "should allow extras to be provided instead :id or :email" do
293
+ it 'should allow extras to be provided instead :id or :email' do
319
294
  user = UserWithOnlyExtras.new
320
- user.properties = {:email => user.email}
321
- expect(user.to_vero).to eq({:email => 'durkster@gmail.com', :_user_type => "UserWithOnlyExtras"})
295
+ user.properties = { email: user.email }
296
+ expect(user.to_vero).to eq({ email: 'durkster@gmail.com', _user_type: 'UserWithOnlyExtras' })
322
297
  end
323
298
  end
324
299
 
325
300
  describe :with_vero_context do
326
- it "should be able to change contexts" do
301
+ it 'should be able to change contexts' do
327
302
  user = User.new
328
- expect(user.with_default_vero_context.config.config_params).to eq({:api_key=>"abcd1234", :secret=>"efgh5678"})
329
- expect(user.with_vero_context({:api_key => "boom", :secret => "tish"}).config.config_params).to eq({:api_key=>"boom", :secret=>"tish"})
303
+ expect(user.with_default_vero_context.config.config_params).to eq({ api_key: 'abcd1234', secret: 'efgh5678' })
304
+ expect(user.with_vero_context({ api_key: 'boom', secret: 'tish' }).config.config_params).to eq({ api_key: 'boom', secret: 'tish' })
330
305
  end
331
306
  end
332
307
 
333
- it "should work when Vero::Trackable::Interface is not included" do
308
+ it 'should work when Vero::Trackable::Interface is not included' do
334
309
  user = UserWithoutInterface.new
335
310
 
336
311
  request_params = {
337
- :event_name => 'test_event',
338
- :auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
339
- :identity => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "UserWithoutInterface"},
340
- :data => { :test => 1 },
341
- :development_mode => true
312
+ event_name: 'test_event',
313
+ auth_token: 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
314
+ identity: { email: 'durkster@gmail.com', age: 20, _user_type: 'UserWithoutInterface' },
315
+ data: { test: 1 },
316
+ development_mode: true
342
317
  }
343
- url = "https://api.getvero.com/api/v1/track.json"
344
318
 
345
319
  context = Vero::Context.new(Vero::App.default_context)
346
320
  context.subject = user
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require 'rails'
@@ -5,9 +7,11 @@ require 'action_view'
5
7
  require 'active_support'
6
8
  require 'vero/view_helpers/javascript'
7
9
 
10
+ # rubocop:disable Style/MixinUsage
8
11
  include Vero::ViewHelpers::Javascript
9
12
  include ActionView::Helpers
10
13
  include ActionView::Context
14
+ # rubocop:enable Style/MixinUsage
11
15
 
12
16
  describe Vero::ViewHelpers::Javascript do
13
17
  before do
@@ -16,17 +20,17 @@ describe Vero::ViewHelpers::Javascript do
16
20
 
17
21
  subject { Vero::ViewHelpers::Javascript }
18
22
  describe :vero_javascript_tag do
19
- it "should return an empty string if Vero::App is not properly configured" do
20
- expect(subject.vero_javascript_tag).to eq("")
23
+ it 'should return an empty string if Vero::App is not properly configured' do
24
+ expect(subject.vero_javascript_tag).to eq('')
21
25
 
22
26
  Vero::App.init {}
23
- expect(subject.vero_javascript_tag).to eq("")
27
+ expect(subject.vero_javascript_tag).to eq('')
24
28
  end
25
29
 
26
- context "Vero::App has been properly configured" do
30
+ context 'Vero::App has been properly configured' do
27
31
  before :each do
28
- @api_key = "abcd1234"
29
- @api_secret = "secret"
32
+ @api_key = 'abcd1234'
33
+ @api_secret = 'secret'
30
34
  @api_dev_mode = false
31
35
 
32
36
  Vero::App.init do |c|
@@ -36,10 +40,10 @@ describe Vero::ViewHelpers::Javascript do
36
40
  end
37
41
  end
38
42
 
39
- it "should return a properly formatted javascript snippet" do
43
+ it 'should return a properly formatted javascript snippet' do
40
44
  result = "<script type=\"text/javascript\">var _veroq = _veroq || [];setTimeout(function(){if(typeof window.Semblance==\"undefined\"){console.log(\"Vero did not load in time.\");for(var i=0;i<_veroq.length;i++){a=_veroq[i];if(a.length==3&&typeof a[2]==\"function\")a[2](null,false);}}},3000);_veroq.push(['init', {\"api_key\": \"#{@api_key}\", \"secret\": \"#{@api_secret}\"}]);(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//getvero.com/assets/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();</script>"
41
45
  expect(subject.vero_javascript_tag).to eq(result)
42
46
  end
43
47
  end
44
48
  end
45
- end
49
+ end