vero 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +15 -1
- data/Gemfile.lock +95 -73
- data/README.markdown +145 -121
- data/lib/generators/vero_generator.rb +18 -19
- data/lib/vero.rb +7 -3
- data/lib/vero/api.rb +14 -4
- data/lib/vero/api/base_api.rb +11 -10
- data/lib/vero/api/events/track_api.rb +5 -3
- data/lib/vero/api/users/delete_api.rb +21 -0
- data/lib/vero/api/users/edit_api.rb +5 -3
- data/lib/vero/api/users/edit_tags_api.rb +7 -5
- data/lib/vero/api/users/reidentify_api.rb +5 -3
- data/lib/vero/api/users/resubscribe_api.rb +3 -1
- data/lib/vero/api/users/track_api.rb +5 -3
- data/lib/vero/api/users/unsubscribe_api.rb +3 -1
- data/lib/vero/app.rb +4 -2
- data/lib/vero/config.rb +11 -8
- data/lib/vero/context.rb +9 -11
- data/lib/vero/context/api.rb +9 -7
- data/lib/vero/dsl.rb +3 -1
- data/lib/vero/railtie.rb +5 -3
- data/lib/vero/sender.rb +12 -31
- data/lib/vero/senders/base.rb +3 -1
- data/lib/vero/senders/delayed_job.rb +7 -7
- data/lib/vero/senders/invalid.rb +5 -3
- data/lib/vero/senders/resque.rb +8 -8
- data/lib/vero/senders/sidekiq.rb +3 -1
- data/lib/vero/senders/{thread.rb → sucker_punch.rb} +5 -3
- data/lib/vero/trackable.rb +4 -2
- data/lib/vero/trackable/base.rb +10 -9
- data/lib/vero/trackable/interface.rb +3 -1
- data/lib/vero/utility/ext.rb +3 -1
- data/lib/vero/utility/logger.rb +4 -6
- data/lib/vero/version.rb +3 -1
- data/lib/vero/view_helpers/javascript.rb +20 -20
- data/spec/lib/api/base_api_spec.rb +10 -8
- data/spec/lib/api/events/track_api_spec.rb +23 -21
- data/spec/lib/api/users/delete_api_spec.rb +33 -0
- data/spec/lib/api/users/edit_api_spec.rb +12 -10
- data/spec/lib/api/users/edit_tags_api_spec.rb +22 -20
- data/spec/lib/api/users/reidentify_spec.rb +16 -14
- data/spec/lib/api/users/resubscribe_api_spec.rb +16 -10
- data/spec/lib/api/users/track_api_spec.rb +21 -19
- data/spec/lib/api/users/unsubscribe_api_spec.rb +12 -10
- data/spec/lib/api_spec.rb +29 -24
- data/spec/lib/app_spec.rb +12 -10
- data/spec/lib/config_spec.rb +31 -29
- data/spec/lib/context_spec.rb +13 -11
- data/spec/lib/dsl_spec.rb +3 -1
- data/spec/lib/sender_spec.rb +12 -24
- data/spec/lib/senders/sidekiq_spec.rb +16 -9
- data/spec/lib/trackable_spec.rb +88 -114
- data/spec/lib/view_helpers_spec.rb +12 -8
- data/spec/spec_helper.rb +10 -4
- data/spec/support/base_config_shared_examples.rb +5 -3
- data/spec/support/user_support.rb +15 -7
- data/spec/support/vero_user_support.rb +4 -2
- data/vero.gemspec +14 -30
- metadata +30 -125
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::BaseAPI do
|
4
|
-
let
|
6
|
+
let(:subject) { Vero::Api::Workers::BaseAPI.new('http://www.getvero.com', {}) }
|
5
7
|
|
6
8
|
describe :options_with_symbolized_keys do
|
7
|
-
it
|
9
|
+
it 'should create a new options Hash with symbol keys (much like Hash#symbolize_keys in rails)' do
|
8
10
|
expect(subject.options).to eq({})
|
9
11
|
|
10
|
-
subject.options = {:
|
11
|
-
expect(subject.options).to eq({:
|
12
|
+
subject.options = { abc: 123 }
|
13
|
+
expect(subject.options).to eq({ abc: 123 })
|
12
14
|
|
13
|
-
subject.options = {
|
14
|
-
expect(subject.options).to eq({:
|
15
|
+
subject.options = { 'abc' => 123 }
|
16
|
+
expect(subject.options).to eq({ abc: 123 })
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
@@ -1,65 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Events::TrackAPI do
|
4
|
-
subject { Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/events/track.json' }
|
8
10
|
end
|
9
11
|
|
10
|
-
context
|
12
|
+
context 'request with properties' do
|
11
13
|
describe :validate! do
|
12
|
-
it
|
13
|
-
options = {:
|
14
|
+
it 'should raise an error if event_name is a blank String' do
|
15
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: nil }
|
14
16
|
subject.options = options
|
15
17
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
16
18
|
|
17
|
-
options = {:
|
19
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }
|
18
20
|
subject.options = options
|
19
21
|
expect { subject.send(:validate!) }.to_not raise_error
|
20
22
|
end
|
21
23
|
|
22
|
-
it
|
23
|
-
options = {:
|
24
|
+
it 'should raise an error if data is not either nil or a Hash' do
|
25
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: [] }
|
24
26
|
subject.options = options
|
25
27
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
26
28
|
|
27
|
-
options = {:
|
29
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: nil }
|
28
30
|
subject.options = options
|
29
31
|
expect { subject.send(:validate!) }.to_not raise_error
|
30
32
|
|
31
|
-
options = {:
|
33
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event', data: {} }
|
32
34
|
subject.options = options
|
33
35
|
expect { subject.send(:validate!) }.to_not raise_error
|
34
36
|
end
|
35
37
|
|
36
|
-
it
|
37
|
-
options = {
|
38
|
+
it 'should not raise an error when the keys are Strings' do
|
39
|
+
options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'event_name' => 'test_event', 'data' => {} }
|
38
40
|
subject.options = options
|
39
41
|
expect { subject.send(:validate!) }.to_not raise_error
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
it 'should not raise an error when keys are Strings for initialization' do
|
43
|
-
options = {
|
45
|
+
options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'event_name' => 'test_event', 'data' => {} }
|
44
46
|
expect { Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', options).send(:validate!) }.to_not raise_error
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
50
|
describe :request do
|
49
|
-
it
|
50
|
-
expect(RestClient).to receive(:post).with(
|
51
|
+
it 'should send a JSON request to the Vero API' do
|
52
|
+
expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/events/track.json', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' }.to_json, { content_type: :json, accept: :json })
|
51
53
|
allow(RestClient).to receive(:post).and_return(200)
|
52
54
|
subject.send(:request)
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
57
|
-
describe
|
58
|
-
it
|
59
|
-
obj = Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', {:
|
59
|
+
describe 'integration test' do
|
60
|
+
it 'should not raise any errors' do
|
61
|
+
obj = Vero::Api::Workers::Events::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, event_name: 'test_event' })
|
60
62
|
|
61
63
|
allow(RestClient).to receive(:post).and_return(200)
|
62
64
|
expect { obj.perform }.to_not raise_error
|
63
65
|
end
|
64
66
|
end
|
65
|
-
end
|
67
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vero::Api::Workers::Users::DeleteAPI do
|
4
|
+
subject { Vero::Api::Workers::Users::DeleteAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :id => '1234'}) }
|
5
|
+
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/delete.json" }
|
8
|
+
end
|
9
|
+
|
10
|
+
it_behaves_like "a Vero wrapper" do
|
11
|
+
let(:end_point) { "/api/v2/users/delete.json" }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe :validate! do
|
15
|
+
it "should not raise an error when the keys are Strings" do
|
16
|
+
subject.options = {"auth_token" => 'abcd', "id" => '1234'}
|
17
|
+
expect { subject.send(:validate!) }.to_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise an error for missing keys" do
|
21
|
+
subject.options = {"auth_token" => 'abcd'}
|
22
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe :request do
|
27
|
+
it "should send a request to the Vero API" do
|
28
|
+
RestClient.should_receive(:post).with("https://api.getvero.com/api/v2/users/delete.json", {:auth_token => 'abcd', :id => '1234'})
|
29
|
+
RestClient.stub(:post).and_return(200)
|
30
|
+
subject.send(:request)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,32 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Users::EditAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/users/edit.json' }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe :validate! do
|
11
|
-
it
|
12
|
-
options = {
|
13
|
+
it 'should not raise an error when the keys are Strings' do
|
14
|
+
options = { 'auth_token' => 'abcd', 'email' => 'test@test.com', 'changes' => { 'email' => 'test@test.com' } }
|
13
15
|
subject.options = options
|
14
16
|
expect { subject.send(:validate!) }.to_not raise_error
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
describe :request do
|
19
|
-
it
|
20
|
-
expect(RestClient).to receive(:put).with(
|
21
|
+
it 'should send a request to the Vero API' do
|
22
|
+
expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/edit.json', { auth_token: 'abcd', email: 'test@test.com', changes: { email: 'test@test.com' } }.to_json, { content_type: :json, accept: :json })
|
21
23
|
allow(RestClient).to receive(:put).and_return(200)
|
22
24
|
subject.send(:request)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
describe
|
27
|
-
it
|
28
|
+
describe 'integration test' do
|
29
|
+
it 'should not raise any errors' do
|
28
30
|
allow(RestClient).to receive(:put).and_return(200)
|
29
31
|
expect { subject.perform }.to_not raise_error
|
30
32
|
end
|
31
33
|
end
|
32
|
-
end
|
34
|
+
end
|
@@ -1,68 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Users::EditTagsAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', { auth_token: 'abcd', email: 'test@test.com', add: ['test'] }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/users/tags/edit.json' }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe :validate! do
|
11
|
-
it
|
12
|
-
options = {:
|
13
|
+
it 'should raise an error if email is a blank String' do
|
14
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: nil, add: [] }
|
13
15
|
subject.options = options
|
14
16
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
15
17
|
|
16
|
-
options = {:
|
18
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', add: [] }
|
17
19
|
subject.options = options
|
18
20
|
expect { subject.send(:validate!) }.to_not raise_error
|
19
21
|
end
|
20
22
|
|
21
|
-
it
|
22
|
-
options = {:
|
23
|
+
it 'should raise an error if add is not an Array or missing' do
|
24
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', add: 'foo' }
|
23
25
|
|
24
26
|
subject.options = options
|
25
27
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
29
|
-
options = {:
|
30
|
+
it 'should raise an error if remove is not an Array or missing' do
|
31
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', remove: 'foo' }
|
30
32
|
|
31
33
|
subject.options = options
|
32
34
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
33
35
|
end
|
34
36
|
|
35
|
-
it
|
36
|
-
options = {:
|
37
|
+
it 'should raise an error if botha add and remove are missing' do
|
38
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }
|
37
39
|
|
38
40
|
subject.options = options
|
39
41
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
40
42
|
end
|
41
43
|
|
42
|
-
it
|
43
|
-
options = {:
|
44
|
+
it 'should not raise an error if the correct arguments are passed' do
|
45
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', remove: ['Hi'] }
|
44
46
|
|
45
47
|
subject.options = options
|
46
48
|
expect { subject.send(:validate!) }.to_not raise_error
|
47
49
|
end
|
48
50
|
|
49
|
-
it
|
50
|
-
options = {
|
51
|
+
it 'should not raise an error when the keys are Strings' do
|
52
|
+
options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'email' => 'test@test.com', 'remove' => ['Hi'] }
|
51
53
|
subject.options = options
|
52
54
|
expect { subject.send(:validate!) }.to_not raise_error
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
58
|
describe :request do
|
57
|
-
it
|
58
|
-
expect(RestClient).to receive(:put).with(
|
59
|
+
it 'should send a request to the Vero API' do
|
60
|
+
expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/tags/edit.json', { auth_token: 'abcd', email: 'test@test.com', add: ['test'] }.to_json, { content_type: :json, accept: :json })
|
59
61
|
allow(RestClient).to receive(:put).and_return(200)
|
60
62
|
subject.send(:request)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
describe
|
65
|
-
it
|
66
|
+
describe 'integration test' do
|
67
|
+
it 'should not raise any errors' do
|
66
68
|
allow(RestClient).to receive(:put).and_return(200)
|
67
69
|
expect { subject.perform }.to_not raise_error
|
68
70
|
end
|
@@ -1,42 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Users::ReidentifyAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', { auth_token: 'abcd', id: 'test@test.com', new_id: 'test2@test.com' }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/users/reidentify.json' }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe :validate! do
|
11
|
-
it
|
12
|
-
options = {
|
13
|
+
it 'should not raise an error when the keys are Strings' do
|
14
|
+
options = { 'auth_token' => 'abcd', 'id' => 'test@test.com', 'new_id' => 'test2@test.com' }
|
13
15
|
subject.options = options
|
14
16
|
expect { subject.send(:validate!) }.to_not raise_error
|
15
17
|
end
|
16
18
|
|
17
|
-
it
|
18
|
-
subject.options = {:
|
19
|
+
it 'should raise an error if id is missing' do
|
20
|
+
subject.options = { auth_token: 'abcd', new_id: 'test2@test.com' }
|
19
21
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
20
22
|
end
|
21
23
|
|
22
|
-
it
|
23
|
-
subject.options = {:
|
24
|
+
it 'should raise an error if new_id is missing' do
|
25
|
+
subject.options = { auth_token: 'abcd', id: 'test@test.com' }
|
24
26
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
describe :request do
|
29
|
-
it
|
30
|
-
expect(RestClient).to receive(:put).with(
|
31
|
+
it 'should send a request to the Vero API' do
|
32
|
+
expect(RestClient).to receive(:put).with('https://api.getvero.com/api/v2/users/reidentify.json', { auth_token: 'abcd', id: 'test@test.com', new_id: 'test2@test.com' }.to_json, { content_type: :json, accept: :json })
|
31
33
|
allow(RestClient).to receive(:put).and_return(200)
|
32
34
|
subject.send(:request)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
|
-
describe
|
37
|
-
it
|
38
|
+
describe 'integration test' do
|
39
|
+
it 'should not raise any errors' do
|
38
40
|
allow(RestClient).to receive(:put).and_return(200)
|
39
41
|
expect { subject.perform }.to_not raise_error
|
40
42
|
end
|
41
43
|
end
|
42
|
-
end
|
44
|
+
end
|
@@ -1,28 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Users::ResubscribeAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::ResubscribeAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Users::ResubscribeAPI.new('https://api.getvero.com', { auth_token: 'abcd', id: '1234' }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/users/resubscribe.json' }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe :validate! do
|
11
|
-
it
|
12
|
-
subject.options = {
|
13
|
+
it 'should not raise an error when the keys are Strings' do
|
14
|
+
subject.options = { 'auth_token' => 'abcd', 'id' => '1234' }
|
13
15
|
expect { subject.send(:validate!) }.to_not raise_error
|
14
16
|
end
|
15
17
|
|
16
|
-
it
|
17
|
-
subject.options = {
|
18
|
+
it 'should raise an error for missing keys' do
|
19
|
+
subject.options = { 'auth_token' => 'abcd' }
|
18
20
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
describe :request do
|
23
|
-
it
|
24
|
-
RestClient
|
25
|
-
|
25
|
+
it 'should send a request to the Vero API' do
|
26
|
+
expect(RestClient).to(
|
27
|
+
receive(:post)
|
28
|
+
.with('https://api.getvero.com/api/v2/users/resubscribe.json', { auth_token: 'abcd', id: '1234' })
|
29
|
+
)
|
30
|
+
allow(RestClient).to receive(:post).and_return(200)
|
31
|
+
|
26
32
|
subject.send(:request)
|
27
33
|
end
|
28
34
|
end
|
@@ -1,64 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Vero::Api::Workers::Users::TrackAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', {:
|
6
|
+
subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }) }
|
5
7
|
|
6
|
-
it_behaves_like
|
7
|
-
let(:end_point) {
|
8
|
+
it_behaves_like 'a Vero wrapper' do
|
9
|
+
let(:end_point) { '/api/v2/users/track.json' }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe :validate! do
|
11
|
-
it
|
12
|
-
options = {:
|
13
|
+
it 'should raise an error if email and id are are blank String' do
|
14
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: nil, email: nil }
|
13
15
|
subject.options = options
|
14
16
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
15
17
|
|
16
|
-
options = {:
|
18
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: nil, email: 'test@test.com' }
|
17
19
|
subject.options = options
|
18
20
|
expect { subject.send(:validate!) }.to_not raise_error
|
19
21
|
|
20
|
-
options = {:
|
22
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: '', email: nil }
|
21
23
|
subject.options = options
|
22
24
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
23
25
|
|
24
|
-
options = {:
|
26
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, id: 'user123', email: nil }
|
25
27
|
subject.options = options
|
26
28
|
expect { subject.send(:validate!) }.to_not raise_error
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
30
|
-
options = {:
|
31
|
+
it 'should raise an error if data is not either nil or a Hash' do
|
32
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: [] }
|
31
33
|
subject.options = options
|
32
34
|
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
33
35
|
|
34
|
-
options = {:
|
36
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: nil }
|
35
37
|
subject.options = options
|
36
38
|
expect { subject.send(:validate!) }.to_not raise_error
|
37
39
|
|
38
|
-
options = {:
|
40
|
+
options = { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com', data: {} }
|
39
41
|
subject.options = options
|
40
42
|
expect { subject.send(:validate!) }.to_not raise_error
|
41
43
|
end
|
42
44
|
|
43
|
-
it
|
44
|
-
options = {
|
45
|
+
it 'should not raise an error when the keys are Strings' do
|
46
|
+
options = { 'auth_token' => 'abcd', 'identity' => { 'email' => 'test@test.com' }, 'email' => 'test@test.com', 'data' => {} }
|
45
47
|
subject.options = options
|
46
48
|
expect { subject.send(:validate!) }.to_not raise_error
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
52
|
describe :request do
|
51
|
-
it
|
52
|
-
expect(RestClient).to receive(:post).with(
|
53
|
+
it 'should send a request to the Vero API' do
|
54
|
+
expect(RestClient).to receive(:post).with('https://api.getvero.com/api/v2/users/track.json', { auth_token: 'abcd', identity: { email: 'test@test.com' }, email: 'test@test.com' }.to_json, { content_type: :json, accept: :json })
|
53
55
|
allow(RestClient).to receive(:post).and_return(200)
|
54
56
|
subject.send(:request)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
describe
|
59
|
-
it
|
60
|
+
describe 'integration test' do
|
61
|
+
it 'should not raise any errors' do
|
60
62
|
allow(RestClient).to receive(:post).and_return(200)
|
61
63
|
expect { subject.perform }.to_not raise_error
|
62
64
|
end
|
63
65
|
end
|
64
|
-
end
|
66
|
+
end
|