vero 0.5.4 → 0.5.6
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/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.markdown +1 -0
- data/lib/vero/api/base_api.rb +11 -0
- data/lib/vero/config.rb +5 -1
- data/lib/vero/context/api.rb +32 -0
- data/lib/vero/context.rb +3 -38
- data/lib/vero/sender.rb +16 -17
- data/lib/vero/version.rb +1 -1
- data/lib/vero.rb +19 -18
- data/spec/lib/api/base_api_spec.rb +17 -0
- data/spec/lib/api/events/track_api_spec.rb +6 -0
- data/spec/lib/api/users/edit_api_spec.rb +5 -0
- data/spec/lib/api/users/edit_tags_api_spec.rb +6 -0
- data/spec/lib/api/users/track_api_spec.rb +6 -0
- data/spec/lib/api/users/unsubscribe_api_spec.rb +5 -0
- data/spec/lib/sender_spec.rb +28 -23
- data/spec/lib/trackable_spec.rb +147 -76
- data/spec/spec_helper.rb +1 -0
- metadata +139 -132
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# vero
|
2
|
+
[](https://travis-ci.org/getvero/vero)
|
2
3
|
|
3
4
|
vero makes it easy to interact with Vero's REST API from your Ruby app. Vero is a user lifecycle platform that allows you to engage and re-engage your customer base via email, based on the actions they perform in your software.
|
4
5
|
|
data/lib/vero/api/base_api.rb
CHANGED
@@ -23,6 +23,10 @@ module Vero
|
|
23
23
|
request
|
24
24
|
end
|
25
25
|
|
26
|
+
def options=(val)
|
27
|
+
@options = options_with_symbolized_keys(val)
|
28
|
+
end
|
29
|
+
|
26
30
|
protected
|
27
31
|
def setup_logging
|
28
32
|
return unless Vero::App.logger
|
@@ -51,6 +55,13 @@ module Vero
|
|
51
55
|
def request_params_as_json
|
52
56
|
JSON.dump(@options)
|
53
57
|
end
|
58
|
+
|
59
|
+
def options_with_symbolized_keys(val)
|
60
|
+
val.inject({}) do |h,(k,v)|
|
61
|
+
h[k.to_sym] = v
|
62
|
+
h
|
63
|
+
end
|
64
|
+
end
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
data/lib/vero/config.rb
CHANGED
@@ -32,7 +32,7 @@ module Vero
|
|
32
32
|
if @domain.blank?
|
33
33
|
'https://www.getvero.com'
|
34
34
|
else
|
35
|
-
@domain =~ /http[s]?\:\/\/.+/ ? @domain : "http://#{@domain}"
|
35
|
+
@domain =~ /http[s]?\:\/\/.+/ ? @domain : "http://#{@domain}"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -49,6 +49,10 @@ module Vero
|
|
49
49
|
auth_token?
|
50
50
|
end
|
51
51
|
|
52
|
+
def disable_requests!
|
53
|
+
self.disabled = true
|
54
|
+
end
|
55
|
+
|
52
56
|
def reset!
|
53
57
|
self.disabled = false
|
54
58
|
self.development_mode = false
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vero
|
2
|
+
module APIContext
|
3
|
+
def track!(event_name, event_data, extras = {})
|
4
|
+
options = {:data => event_data, :event_name => event_name, :identity => subject.to_vero, :extras => extras}
|
5
|
+
Vero::Api::Events.track!(options, self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def identify!
|
9
|
+
data = subject.to_vero
|
10
|
+
options = {:email => data[:email], :data => data}
|
11
|
+
Vero::Api::Users.track!(options, self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def update_user!(email = nil)
|
15
|
+
changes = subject.to_vero
|
16
|
+
options = {:email => (email || changes[:email]), :changes => changes}
|
17
|
+
Vero::Api::Users.edit_user!(options, self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_user_tags!(add = [], remove = [])
|
21
|
+
identity = subject.to_vero
|
22
|
+
options = {:email => identity[:email], :add => add, :remove => remove}
|
23
|
+
Vero::Api::Users.edit_user_tags!(options, self)
|
24
|
+
end
|
25
|
+
|
26
|
+
def unsubscribe!
|
27
|
+
identity = subject.to_vero
|
28
|
+
options = {:email => identity[:email]}
|
29
|
+
Vero::Api::Users.unsubscribe!(options, self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/vero/context.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Vero
|
2
2
|
class Context
|
3
|
+
include Vero::APIContext
|
3
4
|
attr_accessor :config, :subject
|
4
5
|
|
5
6
|
def initialize(object = {})
|
6
7
|
case object
|
7
|
-
when Hash
|
8
|
+
when Hash
|
8
9
|
#stub
|
9
10
|
when Vero::Context
|
10
11
|
@config = object.config
|
@@ -35,47 +36,11 @@ module Vero
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def disable_requests!
|
38
|
-
@config.
|
39
|
+
@config.disable_requests!
|
39
40
|
end
|
40
41
|
|
41
42
|
def configured?
|
42
43
|
@config.configured?
|
43
44
|
end
|
44
|
-
|
45
|
-
### API methods
|
46
|
-
|
47
|
-
def track!(event_name, event_data)
|
48
|
-
options = {:data => event_data, :event_name => event_name, :identity => subject.to_vero}
|
49
|
-
|
50
|
-
Vero::Api::Events.track!(options, self)
|
51
|
-
end
|
52
|
-
|
53
|
-
def identify!
|
54
|
-
data = subject.to_vero
|
55
|
-
options = {:email => data[:email], :data => data}
|
56
|
-
|
57
|
-
Vero::Api::Users.track!(options, self)
|
58
|
-
end
|
59
|
-
|
60
|
-
def update_user!(email = nil)
|
61
|
-
changes = subject.to_vero
|
62
|
-
options = {:email => (email || changes[:email]), :changes => changes}
|
63
|
-
|
64
|
-
Vero::Api::Users.edit_user!(options, self)
|
65
|
-
end
|
66
|
-
|
67
|
-
def update_user_tags!(add = [], remove = [])
|
68
|
-
identity = subject.to_vero
|
69
|
-
options = {:email => identity[:email], :add => add, :remove => remove}
|
70
|
-
|
71
|
-
Vero::Api::Users.edit_user_tags!(options, self)
|
72
|
-
end
|
73
|
-
|
74
|
-
def unsubscribe!
|
75
|
-
identity = subject.to_vero
|
76
|
-
options = {:email => identity[:email]}
|
77
|
-
|
78
|
-
Vero::Api::Users.unsubscribe!(options, self)
|
79
|
-
end
|
80
45
|
end
|
81
46
|
end
|
data/lib/vero/sender.rb
CHANGED
@@ -7,31 +7,30 @@ module Vero
|
|
7
7
|
super
|
8
8
|
else
|
9
9
|
klass_name = key.to_s.split("_").map(&:capitalize).join
|
10
|
-
|
10
|
+
Vero::Senders.const_get(klass_name)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
class Sender
|
16
16
|
def self.senders
|
17
|
-
|
18
|
-
t = Vero::SenderHash.new
|
17
|
+
t = Vero::SenderHash.new
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
t.merge!({
|
20
|
+
true => Vero::Senders::Invalid,
|
21
|
+
false => Vero::Senders::Base,
|
22
|
+
:none => Vero::Senders::Base,
|
23
|
+
:thread => Vero::Senders::Invalid
|
24
|
+
})
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
t
|
26
|
+
if RUBY_VERSION !~ /1\.8\./
|
27
|
+
t.merge!(
|
28
|
+
true => Vero::Senders::Thread,
|
29
|
+
:thread => Vero::Senders::Thread
|
30
|
+
)
|
34
31
|
end
|
32
|
+
|
33
|
+
t
|
35
34
|
end
|
36
35
|
|
37
36
|
def self.send(api_class, sender_strategy, domain, options)
|
@@ -47,4 +46,4 @@ module Vero
|
|
47
46
|
raise e
|
48
47
|
end
|
49
48
|
end
|
50
|
-
end
|
49
|
+
end
|
data/lib/vero/version.rb
CHANGED
data/lib/vero.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'vero/utility/ext'
|
3
3
|
|
4
|
-
module Vero
|
5
|
-
autoload :Config,
|
6
|
-
autoload :App,
|
7
|
-
autoload :Context,
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
|
4
|
+
module Vero
|
5
|
+
autoload :Config, 'vero/config'
|
6
|
+
autoload :App, 'vero/app'
|
7
|
+
autoload :Context, 'vero/context'
|
8
|
+
autoload :APIContext, 'vero/context/api'
|
9
|
+
autoload :Trackable, 'vero/trackable'
|
10
|
+
autoload :DSL, 'vero/dsl'
|
11
|
+
autoload :Sender, 'vero/sender'
|
12
|
+
autoload :ResqueWorker, 'vero/senders/resque'
|
13
|
+
|
11
14
|
module Api
|
12
15
|
module Workers
|
13
16
|
autoload :BaseAPI, 'vero/api/base_api'
|
@@ -27,20 +30,18 @@ module Vero
|
|
27
30
|
autoload :Events, 'vero/api'
|
28
31
|
autoload :Users, 'vero/api'
|
29
32
|
end
|
30
|
-
|
31
|
-
module Utility
|
32
|
-
autoload :Logger, 'vero/utility/logger'
|
33
|
-
end
|
34
33
|
|
35
34
|
module Senders
|
36
|
-
autoload :Base,
|
37
|
-
autoload :DelayedJob,
|
38
|
-
autoload :Resque,
|
39
|
-
autoload :Invalid,
|
40
|
-
autoload :Thread,
|
35
|
+
autoload :Base, 'vero/senders/base'
|
36
|
+
autoload :DelayedJob, 'vero/senders/delayed_job'
|
37
|
+
autoload :Resque, 'vero/senders/resque'
|
38
|
+
autoload :Invalid, 'vero/senders/invalid'
|
39
|
+
autoload :Thread, 'vero/senders/thread'
|
40
|
+
end
|
41
|
+
|
42
|
+
module Utility
|
43
|
+
autoload :Logger, 'vero/utility/logger'
|
41
44
|
end
|
42
|
-
autoload :Sender, 'vero/sender'
|
43
|
-
autoload :ResqueWorker, 'vero/senders/resque'
|
44
45
|
end
|
45
46
|
|
46
47
|
require 'vero/railtie' if defined?(Rails)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Vero::Api::Workers::BaseAPI do
|
4
|
+
let (:subject) { Vero::Api::Workers::BaseAPI.new("http://www.getvero.com", {}) }
|
5
|
+
|
6
|
+
describe :options_with_symbolized_keys do
|
7
|
+
it "should create a new options Hash with symbol keys (much like Hash#symbolize_keys in rails)" do
|
8
|
+
subject.options.should == {}
|
9
|
+
|
10
|
+
subject.options = {:abc => 123}
|
11
|
+
subject.options.should == {:abc => 123}
|
12
|
+
|
13
|
+
subject.options = {"abc" => 123}
|
14
|
+
subject.options.should == {:abc => 123}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -39,6 +39,12 @@ describe Vero::Api::Workers::Events::TrackAPI do
|
|
39
39
|
subject.options = options
|
40
40
|
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
41
41
|
end
|
42
|
+
|
43
|
+
it "should not raise an error when the keys are Strings" do
|
44
|
+
options = {"auth_token" => 'abcd', "identity" => {"email" => 'test@test.com'}, "event_name" => 'test_event', "data" => {}}
|
45
|
+
subject.options = options
|
46
|
+
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
describe :request do
|
@@ -12,6 +12,11 @@ describe Vero::Api::Workers::Users::EditAPI do
|
|
12
12
|
|
13
13
|
subject { Vero::Api::Workers::Users::EditAPI.new('https://www.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
14
14
|
describe :validate! do
|
15
|
+
it "should not raise an error when the keys are Strings" do
|
16
|
+
options = {"auth_token" => 'abcd', "email" => 'test@test.com', "changes" => { "email" => 'test@test.com' }}
|
17
|
+
subject.options = options
|
18
|
+
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
describe :request do
|
@@ -50,6 +50,12 @@ describe Vero::Api::Workers::Users::EditTagsAPI do
|
|
50
50
|
subject.options = options
|
51
51
|
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
52
52
|
end
|
53
|
+
|
54
|
+
it "should not raise an error when the keys are Strings" do
|
55
|
+
options = {"auth_token" => 'abcd', "identity" => {"email" => 'test@test.com'}, "email" => 'test@test.com', "remove" => [ "Hi" ] }
|
56
|
+
subject.options = options
|
57
|
+
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
describe :request do
|
@@ -35,6 +35,12 @@ describe Vero::Api::Workers::Users::TrackAPI do
|
|
35
35
|
subject.options = options
|
36
36
|
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
37
37
|
end
|
38
|
+
|
39
|
+
it "should not raise an error when the keys are Strings" do
|
40
|
+
options = {"auth_token" => 'abcd', "identity" => {"email" => 'test@test.com'}, "email" => 'test@test.com', "data" => {}}
|
41
|
+
subject.options = options
|
42
|
+
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
describe :request do
|
@@ -12,6 +12,11 @@ describe Vero::Api::Workers::Users::UnsubscribeAPI do
|
|
12
12
|
|
13
13
|
subject { Vero::Api::Workers::Users::UnsubscribeAPI.new('https://www.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
14
14
|
describe :validate! do
|
15
|
+
it "should not raise an error when the keys are Strings" do
|
16
|
+
options = {"auth_token" => 'abcd', "email" => 'test@test.com', "changes" => { "email" => 'test@test.com' }}
|
17
|
+
subject.options = options
|
18
|
+
expect { subject.send(:validate!) }.to_not raise_error(ArgumentError)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
describe :request do
|
data/spec/lib/sender_spec.rb
CHANGED
@@ -2,34 +2,39 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Vero::Sender do
|
4
4
|
subject { Vero::Sender }
|
5
|
-
|
5
|
+
|
6
|
+
describe ".senders" do
|
6
7
|
it "should be a Hash" do
|
7
8
|
subject.senders.should be_a(Hash)
|
8
9
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
|
11
|
+
context 'when using Ruby 1.8' do
|
12
|
+
before do
|
13
|
+
stub_const('RUBY_VERSION', '1.8.7')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have a default set of senders (true, false, none, thread)" do
|
17
|
+
subject.senders.should == {
|
18
|
+
true => Vero::Senders::Invalid,
|
19
|
+
false => Vero::Senders::Base,
|
20
|
+
:none => Vero::Senders::Base,
|
21
|
+
:thread => Vero::Senders::Invalid,
|
22
|
+
}
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
context 'when using Ruby with verion greater than 1.8.7' do
|
27
|
+
before do
|
28
|
+
stub_const('RUBY_VERSION', '1.9.3')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have a default set of senders (true, false, none, thread)" do
|
32
|
+
subject.senders.should == {
|
33
|
+
true => Vero::Senders::Thread,
|
34
|
+
false => Vero::Senders::Base,
|
35
|
+
:none => Vero::Senders::Base,
|
36
|
+
:thread => Vero::Senders::Thread,
|
37
|
+
}
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
@@ -40,4 +45,4 @@ describe Vero::Sender do
|
|
40
45
|
subject.senders[:none].should == Vero::Senders::Base
|
41
46
|
end
|
42
47
|
end
|
43
|
-
end
|
48
|
+
end
|
data/spec/lib/trackable_spec.rb
CHANGED
@@ -49,8 +49,7 @@ describe Vero::Trackable do
|
|
49
49
|
:event_name => 'test_event',
|
50
50
|
:identity => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"},
|
51
51
|
:data => { :test => 1 },
|
52
|
-
:
|
53
|
-
:development_mode => true
|
52
|
+
:extras => {}
|
54
53
|
}
|
55
54
|
@url = "https://www.getvero.com/api/v1/track.json"
|
56
55
|
end
|
@@ -70,47 +69,59 @@ describe Vero::Trackable do
|
|
70
69
|
|
71
70
|
RestClient.stub(:post).and_return(200)
|
72
71
|
|
73
|
-
RestClient.should_receive(:post).with("https://www.getvero.com/api/v2/events/track.json", {:data=>{:test=>1}, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20, :_user_type=>"User"}, :auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true}.to_json, @content_type_params)
|
72
|
+
# RestClient.should_receive(:post).with("https://www.getvero.com/api/v2/events/track.json", {:data=>{:test=>1}, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20, :_user_type=>"User"}, :auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true}.to_json, @content_type_params)
|
73
|
+
|
74
|
+
Vero::Api::Events.stub(:track!).and_return(200)
|
75
|
+
Vero::Api::Events.should_receive(:track!).with(@request_params, context)
|
74
76
|
@user.track!(@request_params[:event_name], @request_params[:data]).should == 200
|
75
77
|
|
76
|
-
RestClient.should_receive(:post).with("https://www.getvero.com/api/v2/events/track.json", {:data=>{}, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20, :_user_type=>"User"}, :auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true}.to_json, @content_type_params)
|
78
|
+
# RestClient.should_receive(:post).with("https://www.getvero.com/api/v2/events/track.json", {:data=>{}, :event_name=>"test_event", :identity=>{:email=>"durkster@gmail.com", :age=>20, :_user_type=>"User"}, :auth_token=>"YWJjZDEyMzQ6ZWZnaDU2Nzg=", :development_mode=>true}.to_json, @content_type_params)
|
79
|
+
|
80
|
+
Vero::Api::Events.stub(:track!).and_return(200)
|
81
|
+
Vero::Api::Events.should_receive(:track!).with(@request_params.merge(:data => {}), context)
|
77
82
|
@user.track!(@request_params[:event_name]).should == 200
|
78
83
|
end
|
79
84
|
|
80
|
-
|
81
|
-
|
82
|
-
context.config.logging = true
|
83
|
-
context.subject = @user
|
84
|
-
context.config.async = true
|
85
|
+
context 'when set to be async' do
|
86
|
+
let(:my_context) { Vero::Context.new(Vero::App.default_context) }
|
85
87
|
|
86
|
-
|
88
|
+
before do
|
89
|
+
my_context.config.logging = true
|
90
|
+
my_context.subject = @user
|
91
|
+
my_context.config.async = true
|
87
92
|
|
88
|
-
|
89
|
-
@user.track!(@request_params[:event_name], @request_params[:data]).should be_true
|
90
|
-
@user.track!(@request_params[:event_name]).should be_true
|
91
|
-
else
|
92
|
-
expect { @user.track!(@request_params[:event_name], @request_params[:data]) }.to raise_error
|
93
|
-
expect { @user.track!(@request_params[:event_name]) }.to raise_error
|
93
|
+
@user.stub(:with_vero_context).and_return(my_context)
|
94
94
|
end
|
95
|
-
end
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# context.config.domain = "200.200.200.200"
|
96
|
+
context 'using Ruby 1.8.7' do
|
97
|
+
before do
|
98
|
+
stub_const('RUBY_VERSION', '1.8.7')
|
99
|
+
end
|
102
100
|
|
103
|
-
|
104
|
-
|
101
|
+
it 'raises an error' do
|
102
|
+
expect { @user.track!(@request_params[:event_name], @request_params[:data]) }.to raise_error
|
103
|
+
expect { @user.track!(@request_params[:event_name]) }.to raise_error
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'not using Ruby 1.8.7' do
|
108
|
+
before do
|
109
|
+
stub_const('RUBY_VERSION', '1.9.3')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'sends' do
|
113
|
+
@user.track!(@request_params[:event_name], @request_params[:data]).should be_true
|
114
|
+
@user.track!(@request_params[:event_name]).should be_true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
105
118
|
end
|
106
119
|
|
107
120
|
describe :identify! do
|
108
121
|
before do
|
109
122
|
@request_params = {
|
110
123
|
:email => 'durkster@gmail.com',
|
111
|
-
:data => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"}
|
112
|
-
:auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
113
|
-
:development_mode => true
|
124
|
+
:data => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"}
|
114
125
|
}
|
115
126
|
@url = "https://www.getvero.com/api/v2/users/track.json"
|
116
127
|
end
|
@@ -121,23 +132,41 @@ describe Vero::Trackable do
|
|
121
132
|
|
122
133
|
@user.stub(:with_vero_context).and_return(context)
|
123
134
|
|
124
|
-
RestClient.stub(:post).and_return(200)
|
125
|
-
RestClient.should_receive(:post).with(@url, @request_params.to_json, @content_type_params)
|
126
|
-
|
135
|
+
# RestClient.stub(:post).and_return(200)
|
136
|
+
# RestClient.should_receive(:post).with(@url, @request_params.to_json, @content_type_params)
|
137
|
+
|
138
|
+
Vero::Api::Users.stub(:track!).and_return(200)
|
139
|
+
Vero::Api::Users.should_receive(:track!).with(@request_params, context)
|
140
|
+
|
127
141
|
@user.identify!.should == 200
|
128
142
|
end
|
129
143
|
|
130
|
-
|
131
|
-
|
132
|
-
context.subject = @user
|
133
|
-
context.config.async = true
|
144
|
+
context 'when set to use async' do
|
145
|
+
let(:my_context) { Vero::Context.new(Vero::App.default_context) }
|
134
146
|
|
135
|
-
|
147
|
+
before do
|
148
|
+
my_context.subject = @user
|
149
|
+
my_context.config.async = true
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'and using Ruby 1.8.7' do
|
153
|
+
before do
|
154
|
+
stub_const('RUBY_VERSION', '1.8.7')
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'raises an error' do
|
158
|
+
expect { @user.identify! }.to raise_error
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'and not using Ruby 1.8.7' do
|
163
|
+
before do
|
164
|
+
stub_const('RUBY_VERSION', '1.9.3')
|
165
|
+
end
|
136
166
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
expect { @user.identify! }.to raise_error
|
167
|
+
it 'sends' do
|
168
|
+
@user.identify!.should be_true
|
169
|
+
end
|
141
170
|
end
|
142
171
|
end
|
143
172
|
end
|
@@ -147,8 +176,6 @@ describe Vero::Trackable do
|
|
147
176
|
@request_params = {
|
148
177
|
:email => 'durkster@gmail.com',
|
149
178
|
:changes => {:email => 'durkster@gmail.com', :age => 20, :_user_type => "User"},
|
150
|
-
:auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
151
|
-
:development_mode => true
|
152
179
|
}
|
153
180
|
@url = "https://www.getvero.com/api/v2/users/edit.json"
|
154
181
|
end
|
@@ -159,9 +186,12 @@ describe Vero::Trackable do
|
|
159
186
|
|
160
187
|
@user.stub(:with_vero_context).and_return(context)
|
161
188
|
|
162
|
-
RestClient.stub(:put).and_return(200)
|
163
|
-
RestClient.should_receive(:put).with(@url, @request_params.merge(:email => "durkster1@gmail.com").to_json, @content_type_params)
|
164
|
-
|
189
|
+
# RestClient.stub(:put).and_return(200)
|
190
|
+
# RestClient.should_receive(:put).with(@url, @request_params.merge(:email => "durkster1@gmail.com").to_json, @content_type_params)
|
191
|
+
|
192
|
+
Vero::Api::Users.stub(:edit_user!).and_return(200)
|
193
|
+
Vero::Api::Users.should_receive(:edit_user!).with(@request_params.merge(:email => "durkster1@gmail.com"), context)
|
194
|
+
|
165
195
|
@user.with_vero_context.update_user!("durkster1@gmail.com").should == 200
|
166
196
|
end
|
167
197
|
|
@@ -171,23 +201,43 @@ describe Vero::Trackable do
|
|
171
201
|
|
172
202
|
@user.stub(:with_vero_context).and_return(context)
|
173
203
|
|
174
|
-
RestClient.stub(:put).and_return(200)
|
175
|
-
RestClient.should_receive(:put).with(@url, @request_params.to_json, @content_type_params)
|
176
|
-
|
204
|
+
# RestClient.stub(:put).and_return(200)
|
205
|
+
# RestClient.should_receive(:put).with(@url, @request_params.to_json, @content_type_params)
|
206
|
+
|
207
|
+
Vero::Api::Users.stub(:edit_user!).and_return(200)
|
208
|
+
Vero::Api::Users.should_receive(:edit_user!).with(@request_params, context)
|
209
|
+
|
177
210
|
@user.with_vero_context.update_user!.should == 200
|
178
211
|
end
|
179
212
|
|
180
|
-
|
181
|
-
|
182
|
-
context.subject = @user
|
183
|
-
context.config.async = true
|
213
|
+
context 'when set to use async' do
|
214
|
+
let(:my_context) { Vero::Context.new(Vero::App.default_context) }
|
184
215
|
|
185
|
-
|
216
|
+
before do
|
217
|
+
my_context.subject = @user
|
218
|
+
my_context.config.async = true
|
219
|
+
|
220
|
+
@user.stub(:with_vero_context).and_return(my_context)
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'and using Ruby 1.8.7' do
|
224
|
+
before do
|
225
|
+
stub_const('RUBY_VERSION', '1.8.7')
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'raises an error' do
|
229
|
+
expect { @user.with_vero_context.update_user! }.to raise_error
|
230
|
+
end
|
231
|
+
end
|
186
232
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
233
|
+
context 'and not using Ruby 1.8.7' do
|
234
|
+
before do
|
235
|
+
stub_const('RUBY_VERSION', '1.9.3')
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'sends' do
|
239
|
+
@user.with_vero_context.update_user!.should be_true
|
240
|
+
end
|
191
241
|
end
|
192
242
|
end
|
193
243
|
end
|
@@ -197,9 +247,7 @@ describe Vero::Trackable do
|
|
197
247
|
@request_params = {
|
198
248
|
:email => 'durkster@gmail.com',
|
199
249
|
:add => [],
|
200
|
-
:remove => []
|
201
|
-
:auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
202
|
-
:development_mode => true
|
250
|
+
:remove => []
|
203
251
|
}
|
204
252
|
@url = "https://www.getvero.com/api/v2/users/tags/edit.json"
|
205
253
|
end
|
@@ -211,9 +259,12 @@ describe Vero::Trackable do
|
|
211
259
|
|
212
260
|
@user.stub(:with_vero_context).and_return(context)
|
213
261
|
|
214
|
-
RestClient.stub(:put).and_return(200)
|
215
|
-
RestClient.should_receive(:put).with(@url, @request_params.to_json, @content_type_params)
|
216
|
-
|
262
|
+
# RestClient.stub(:put).and_return(200)
|
263
|
+
# RestClient.should_receive(:put).with(@url, @request_params.to_json, @content_type_params)
|
264
|
+
|
265
|
+
Vero::Api::Users.stub(:edit_user_tags!).and_return(200)
|
266
|
+
Vero::Api::Users.should_receive(:edit_user_tags!).with(@request_params, context)
|
267
|
+
|
217
268
|
@user.with_vero_context.update_user_tags!.should == 200
|
218
269
|
end
|
219
270
|
|
@@ -233,9 +284,7 @@ describe Vero::Trackable do
|
|
233
284
|
describe :unsubscribe! do
|
234
285
|
before do
|
235
286
|
@request_params = {
|
236
|
-
:email => 'durkster@gmail.com'
|
237
|
-
:auth_token => 'YWJjZDEyMzQ6ZWZnaDU2Nzg=',
|
238
|
-
:development_mode => true
|
287
|
+
:email => 'durkster@gmail.com'
|
239
288
|
}
|
240
289
|
@url = "https://www.getvero.com/api/v2/users/unsubscribe.json"
|
241
290
|
end
|
@@ -247,21 +296,43 @@ describe Vero::Trackable do
|
|
247
296
|
|
248
297
|
@user.stub(:with_vero_context).and_return(context)
|
249
298
|
|
250
|
-
RestClient.stub(:post).and_return(200)
|
251
|
-
RestClient.should_receive(:post).with(@url, @request_params)
|
252
|
-
|
299
|
+
# RestClient.stub(:post).and_return(200)
|
300
|
+
# RestClient.should_receive(:post).with(@url, @request_params)
|
301
|
+
|
302
|
+
Vero::Api::Users.stub(:unsubscribe!).and_return(200)
|
303
|
+
Vero::Api::Users.should_receive(:unsubscribe!).with(@request_params, context)
|
304
|
+
|
253
305
|
@user.with_vero_context.unsubscribe!.should == 200
|
254
306
|
end
|
255
307
|
|
256
|
-
|
257
|
-
|
258
|
-
context = Vero::Context.new(Vero::App.default_context)
|
259
|
-
context.subject = @user
|
260
|
-
context.config.async = true
|
308
|
+
context 'when using async' do
|
309
|
+
let(:my_context) { Vero::Context.new(Vero::App.default_context) }
|
261
310
|
|
262
|
-
|
311
|
+
before do
|
312
|
+
my_context.subject = @user
|
313
|
+
my_context.config.async = true
|
263
314
|
|
264
|
-
@user.with_vero_context.
|
315
|
+
@user.stub(:with_vero_context).and_return(my_context)
|
316
|
+
end
|
317
|
+
|
318
|
+
context 'and using Ruby 1.8.7' do
|
319
|
+
before do
|
320
|
+
stub_const('RUBY_VERSION', '1.8.7')
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'raises an error' do
|
324
|
+
expect { @user.with_vero_context.unsubscribe! }.to raise_error
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
context 'and using Ruby 1.9.3' do
|
329
|
+
before do
|
330
|
+
stub_const('RUBY_VERSION', '1.9.3')
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'sends' do
|
334
|
+
@user.with_vero_context.unsubscribe!.should be_true
|
335
|
+
end
|
265
336
|
end
|
266
337
|
end
|
267
338
|
end
|
@@ -336,7 +407,7 @@ describe Vero::Trackable do
|
|
336
407
|
user.with_vero_context({:api_key => "boom", :secret => "tish"}).config.config_params.should == {:api_key=>"boom", :secret=>"tish"}
|
337
408
|
end
|
338
409
|
end
|
339
|
-
|
410
|
+
|
340
411
|
it "should work when Vero::Trackable::Interface is not included" do
|
341
412
|
user = UserWithoutInterface.new
|
342
413
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,150 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vero
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 6
|
10
|
+
version: 0.5.6
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- James Lamont
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-04-16 00:00:00 +10:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: rails
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>'
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3'
|
22
|
-
type: :development
|
23
23
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
version: "3"
|
38
33
|
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
39
37
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
54
47
|
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: delayed_job
|
55
51
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
70
61
|
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: delayed_job_active_record
|
71
65
|
prerelease: false
|
72
|
-
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
86
75
|
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: resque
|
87
79
|
prerelease: false
|
88
|
-
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
95
92
|
name: json
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :runtime
|
103
93
|
prerelease: false
|
104
|
-
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
118
103
|
type: :runtime
|
104
|
+
version_requirements: *id006
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rest-client
|
119
107
|
prerelease: false
|
120
|
-
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
108
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
134
117
|
type: :runtime
|
118
|
+
version_requirements: *id007
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: girl_friday
|
135
121
|
prerelease: false
|
136
|
-
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- -
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
122
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
type: :runtime
|
132
|
+
version_requirements: *id008
|
142
133
|
description:
|
143
134
|
email: support@getvero.com
|
144
135
|
executables: []
|
136
|
+
|
145
137
|
extensions: []
|
138
|
+
|
146
139
|
extra_rdoc_files: []
|
147
|
-
|
140
|
+
|
141
|
+
files:
|
148
142
|
- Gemfile
|
149
143
|
- Gemfile.lock
|
150
144
|
- lib/generators/vero_generator.rb
|
@@ -157,6 +151,7 @@ files:
|
|
157
151
|
- lib/vero/api.rb
|
158
152
|
- lib/vero/app.rb
|
159
153
|
- lib/vero/config.rb
|
154
|
+
- lib/vero/context/api.rb
|
160
155
|
- lib/vero/context.rb
|
161
156
|
- lib/vero/dsl.rb
|
162
157
|
- lib/vero/railtie.rb
|
@@ -175,6 +170,7 @@ files:
|
|
175
170
|
- lib/vero/view_helpers/javascript.rb
|
176
171
|
- lib/vero.rb
|
177
172
|
- README.markdown
|
173
|
+
- spec/lib/api/base_api_spec.rb
|
178
174
|
- spec/lib/api/events/track_api_spec.rb
|
179
175
|
- spec/lib/api/users/edit_api_spec.rb
|
180
176
|
- spec/lib/api/users/edit_tags_api_spec.rb
|
@@ -192,31 +188,42 @@ files:
|
|
192
188
|
- spec/support/user_support.rb
|
193
189
|
- spec/support/vero_user_support.rb
|
194
190
|
- vero.gemspec
|
191
|
+
has_rdoc: true
|
195
192
|
homepage: http://www.getvero.com/
|
196
193
|
licenses: []
|
194
|
+
|
197
195
|
post_install_message:
|
198
196
|
rdoc_options: []
|
199
|
-
|
197
|
+
|
198
|
+
require_paths:
|
200
199
|
- lib
|
201
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
201
|
none: false
|
203
|
-
requirements:
|
204
|
-
- -
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
|
207
|
-
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
hash: 3
|
206
|
+
segments:
|
207
|
+
- 0
|
208
|
+
version: "0"
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
210
|
none: false
|
209
|
-
requirements:
|
210
|
-
- -
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
hash: 3
|
215
|
+
segments:
|
216
|
+
- 0
|
217
|
+
version: "0"
|
213
218
|
requirements: []
|
219
|
+
|
214
220
|
rubyforge_project:
|
215
|
-
rubygems_version: 1.
|
221
|
+
rubygems_version: 1.6.2
|
216
222
|
signing_key:
|
217
223
|
specification_version: 3
|
218
224
|
summary: Ruby gem for Vero
|
219
|
-
test_files:
|
225
|
+
test_files:
|
226
|
+
- spec/lib/api/base_api_spec.rb
|
220
227
|
- spec/lib/api/events/track_api_spec.rb
|
221
228
|
- spec/lib/api/users/edit_api_spec.rb
|
222
229
|
- spec/lib/api/users/edit_tags_api_spec.rb
|