vero 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +4 -0
- data/Gemfile.lock +57 -47
- data/README.markdown +7 -16
- data/lib/vero.rb +3 -0
- data/lib/vero/api.rb +10 -4
- data/lib/vero/api/base_api.rb +1 -1
- data/lib/vero/api/users/resubscribe_api.rb +21 -0
- data/lib/vero/sender.rb +1 -0
- data/lib/vero/senders/sidekiq.rb +23 -0
- data/lib/vero/version.rb +1 -1
- data/spec/lib/api/base_api_spec.rb +3 -3
- data/spec/lib/api/events/track_api_spec.rb +13 -15
- data/spec/lib/api/users/edit_api_spec.rb +6 -10
- data/spec/lib/api/users/edit_tags_api_spec.rb +10 -15
- data/spec/lib/api/users/reidentify_spec.rb +8 -12
- data/spec/lib/api/users/resubscribe_api_spec.rb +29 -0
- data/spec/lib/api/users/track_api_spec.rb +9 -13
- data/spec/lib/api/users/unsubscribe_api_spec.rb +6 -10
- data/spec/lib/api_spec.rb +48 -55
- data/spec/lib/app_spec.rb +9 -9
- data/spec/lib/config_spec.rb +52 -44
- data/spec/lib/context_spec.rb +16 -16
- data/spec/lib/sender_spec.rb +8 -7
- data/spec/lib/senders/sidekiq_spec.rb +25 -0
- data/spec/lib/trackable_spec.rb +63 -63
- data/spec/lib/view_helpers_spec.rb +3 -3
- data/spec/support/base_config_shared_examples.rb +9 -0
- data/vero-0.8.1.gem +0 -0
- data/vero.gemspec +3 -2
- metadata +67 -24
- checksums.yaml +0 -7
@@ -1,16 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Api::Workers::Users::EditAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', {}) }
|
5
|
-
it "should inherit from Vero::Api::Workers::BaseCaller" do
|
6
|
-
subject.should be_a(Vero::Api::Workers::BaseAPI)
|
7
|
-
end
|
4
|
+
subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/edit.json" }
|
11
8
|
end
|
12
9
|
|
13
|
-
subject { Vero::Api::Workers::Users::EditAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
14
10
|
describe :validate! do
|
15
11
|
it "should not raise an error when the keys are Strings" do
|
16
12
|
options = {"auth_token" => 'abcd', "email" => 'test@test.com', "changes" => { "email" => 'test@test.com' }}
|
@@ -21,15 +17,15 @@ describe Vero::Api::Workers::Users::EditAPI do
|
|
21
17
|
|
22
18
|
describe :request do
|
23
19
|
it "should send a request to the Vero API" do
|
24
|
-
RestClient.
|
25
|
-
RestClient.
|
20
|
+
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
|
+
allow(RestClient).to receive(:put).and_return(200)
|
26
22
|
subject.send(:request)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
26
|
describe "integration test" do
|
31
27
|
it "should not raise any errors" do
|
32
|
-
RestClient.
|
28
|
+
allow(RestClient).to receive(:put).and_return(200)
|
33
29
|
expect { subject.perform }.to_not raise_error
|
34
30
|
end
|
35
31
|
end
|
@@ -1,22 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Api::Workers::Users::EditTagsAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', {}) }
|
5
|
-
it "should inherit from Vero::Api::Workers::BaseCaller" do
|
6
|
-
subject.should be_a(Vero::Api::Workers::BaseAPI)
|
7
|
-
end
|
4
|
+
subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :add => ["test"]}) }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/tags/edit.json" }
|
11
8
|
end
|
12
9
|
|
13
|
-
subject { Vero::Api::Workers::Users::EditTagsAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :add => ["test"]}) }
|
14
|
-
|
15
10
|
describe :validate! do
|
16
11
|
it "should raise an error if email is a blank String" do
|
17
12
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => nil, :add => []}
|
18
13
|
subject.options = options
|
19
|
-
expect { subject.send(:validate!) }.to raise_error
|
14
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
20
15
|
|
21
16
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com', :add => []}
|
22
17
|
subject.options = options
|
@@ -27,21 +22,21 @@ describe Vero::Api::Workers::Users::EditTagsAPI do
|
|
27
22
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com', :add => "foo" }
|
28
23
|
|
29
24
|
subject.options = options
|
30
|
-
expect { subject.send(:validate!) }.to raise_error
|
25
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
31
26
|
end
|
32
27
|
|
33
28
|
it "should raise an error if remove is not an Array or missing" do
|
34
29
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com', :remove => "foo" }
|
35
30
|
|
36
31
|
subject.options = options
|
37
|
-
expect { subject.send(:validate!) }.to raise_error
|
32
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
38
33
|
end
|
39
34
|
|
40
35
|
it "should raise an error if botha add and remove are missing" do
|
41
36
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com'}
|
42
37
|
|
43
38
|
subject.options = options
|
44
|
-
expect { subject.send(:validate!) }.to raise_error
|
39
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
45
40
|
end
|
46
41
|
|
47
42
|
it "should not raise an error if the correct arguments are passed" do
|
@@ -60,15 +55,15 @@ describe Vero::Api::Workers::Users::EditTagsAPI do
|
|
60
55
|
|
61
56
|
describe :request do
|
62
57
|
it "should send a request to the Vero API" do
|
63
|
-
RestClient.
|
64
|
-
RestClient.
|
58
|
+
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
|
+
allow(RestClient).to receive(:put).and_return(200)
|
65
60
|
subject.send(:request)
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
64
|
describe "integration test" do
|
70
65
|
it "should not raise any errors" do
|
71
|
-
RestClient.
|
66
|
+
allow(RestClient).to receive(:put).and_return(200)
|
72
67
|
expect { subject.perform }.to_not raise_error
|
73
68
|
end
|
74
69
|
end
|
@@ -1,16 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Api::Workers::Users::ReidentifyAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', {}) }
|
5
|
-
it "should inherit from Vero::Api::Workers::BaseCaller" do
|
6
|
-
subject.should be_a(Vero::Api::Workers::BaseAPI)
|
7
|
-
end
|
4
|
+
subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :id => 'test@test.com', :new_id => 'test2@test.com'}) }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/reidentify.json" }
|
11
8
|
end
|
12
9
|
|
13
|
-
subject { Vero::Api::Workers::Users::ReidentifyAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :id => 'test@test.com', :new_id => 'test2@test.com'}) }
|
14
10
|
describe :validate! do
|
15
11
|
it "should not raise an error when the keys are Strings" do
|
16
12
|
options = {"auth_token" => 'abcd', "id" => 'test@test.com', "new_id" => 'test2@test.com'}
|
@@ -20,26 +16,26 @@ describe Vero::Api::Workers::Users::ReidentifyAPI do
|
|
20
16
|
|
21
17
|
it "should raise an error if id is missing" do
|
22
18
|
subject.options = {:auth_token => 'abcd', :new_id => 'test2@test.com'}
|
23
|
-
expect { subject.send(:validate!) }.to raise_error
|
19
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
24
20
|
end
|
25
21
|
|
26
22
|
it "should raise an error if new_id is missing" do
|
27
23
|
subject.options = {:auth_token => 'abcd', :id => 'test@test.com'}
|
28
|
-
expect { subject.send(:validate!) }.to raise_error
|
24
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
28
|
describe :request do
|
33
29
|
it "should send a request to the Vero API" do
|
34
|
-
RestClient.
|
35
|
-
RestClient.
|
30
|
+
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
|
+
allow(RestClient).to receive(:put).and_return(200)
|
36
32
|
subject.send(:request)
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
36
|
describe "integration test" do
|
41
37
|
it "should not raise any errors" do
|
42
|
-
RestClient.
|
38
|
+
allow(RestClient).to receive(:put).and_return(200)
|
43
39
|
expect { subject.perform }.to_not raise_error
|
44
40
|
end
|
45
41
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vero::Api::Workers::Users::ResubscribeAPI do
|
4
|
+
subject { Vero::Api::Workers::Users::ResubscribeAPI.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/resubscribe.json" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe :validate! do
|
11
|
+
it "should not raise an error when the keys are Strings" do
|
12
|
+
subject.options = {"auth_token" => 'abcd', "id" => '1234'}
|
13
|
+
expect { subject.send(:validate!) }.to_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should raise an error for missing keys" do
|
17
|
+
subject.options = {"auth_token" => 'abcd'}
|
18
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :request do
|
23
|
+
it "should send a request to the Vero API" do
|
24
|
+
RestClient.should_receive(:post).with("https://api.getvero.com/api/v2/users/resubscribe.json", {:auth_token => 'abcd', :id => '1234'})
|
25
|
+
RestClient.stub(:post).and_return(200)
|
26
|
+
subject.send(:request)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Api::Workers::Users::TrackAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', {}) }
|
5
|
-
it "should inherit from Vero::Api::Workers::BaseCaller" do
|
6
|
-
subject.should be_a(Vero::Api::Workers::BaseAPI)
|
7
|
-
end
|
4
|
+
subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com'}) }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/track.json" }
|
11
8
|
end
|
12
9
|
|
13
|
-
subject { Vero::Api::Workers::Users::TrackAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com'}) }
|
14
10
|
describe :validate! do
|
15
11
|
it "should raise an error if email and id are are blank String" do
|
16
12
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :id => nil, :email => nil}
|
17
13
|
subject.options = options
|
18
|
-
expect { subject.send(:validate!) }.to raise_error
|
14
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
19
15
|
|
20
16
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :id => nil, :email => 'test@test.com'}
|
21
17
|
subject.options = options
|
@@ -23,7 +19,7 @@ describe Vero::Api::Workers::Users::TrackAPI do
|
|
23
19
|
|
24
20
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :id => "", :email => nil}
|
25
21
|
subject.options = options
|
26
|
-
expect { subject.send(:validate!) }.to raise_error
|
22
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
27
23
|
|
28
24
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :id => "user123", :email => nil}
|
29
25
|
subject.options = options
|
@@ -33,7 +29,7 @@ describe Vero::Api::Workers::Users::TrackAPI do
|
|
33
29
|
it "should raise an error if data is not either nil or a Hash" do
|
34
30
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com', :data => []}
|
35
31
|
subject.options = options
|
36
|
-
expect { subject.send(:validate!) }.to raise_error
|
32
|
+
expect { subject.send(:validate!) }.to raise_error(ArgumentError)
|
37
33
|
|
38
34
|
options = {:auth_token => 'abcd', :identity => {:email => 'test@test.com'}, :email => 'test@test.com', :data => nil}
|
39
35
|
subject.options = options
|
@@ -53,15 +49,15 @@ describe Vero::Api::Workers::Users::TrackAPI do
|
|
53
49
|
|
54
50
|
describe :request do
|
55
51
|
it "should send a request to the Vero API" do
|
56
|
-
RestClient.
|
57
|
-
RestClient.
|
52
|
+
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
|
+
allow(RestClient).to receive(:post).and_return(200)
|
58
54
|
subject.send(:request)
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
58
|
describe "integration test" do
|
63
59
|
it "should not raise any errors" do
|
64
|
-
RestClient.
|
60
|
+
allow(RestClient).to receive(:post).and_return(200)
|
65
61
|
expect { subject.perform }.to_not raise_error
|
66
62
|
end
|
67
63
|
end
|
@@ -1,16 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vero::Api::Workers::Users::UnsubscribeAPI do
|
4
|
-
subject { Vero::Api::Workers::Users::UnsubscribeAPI.new('https://api.getvero.com', {}) }
|
5
|
-
it "should inherit from Vero::Api::Workers::BaseCaller" do
|
6
|
-
subject.should be_a(Vero::Api::Workers::BaseAPI)
|
7
|
-
end
|
4
|
+
subject { Vero::Api::Workers::Users::UnsubscribeAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
it_behaves_like "a Vero wrapper" do
|
7
|
+
let(:end_point) { "/api/v2/users/unsubscribe.json" }
|
11
8
|
end
|
12
9
|
|
13
|
-
subject { Vero::Api::Workers::Users::UnsubscribeAPI.new('https://api.getvero.com', {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }}) }
|
14
10
|
describe :validate! do
|
15
11
|
it "should not raise an error when the keys are Strings" do
|
16
12
|
options = {"auth_token" => 'abcd', "email" => 'test@test.com', "changes" => { "email" => 'test@test.com' }}
|
@@ -21,15 +17,15 @@ describe Vero::Api::Workers::Users::UnsubscribeAPI do
|
|
21
17
|
|
22
18
|
describe :request do
|
23
19
|
it "should send a request to the Vero API" do
|
24
|
-
RestClient.
|
25
|
-
RestClient.
|
20
|
+
expect(RestClient).to receive(:post).with("https://api.getvero.com/api/v2/users/unsubscribe.json", {:auth_token => 'abcd', :email => 'test@test.com', :changes => { :email => 'test@test.com' }})
|
21
|
+
allow(RestClient).to receive(:post).and_return(200)
|
26
22
|
subject.send(:request)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
26
|
describe "integration test" do
|
31
27
|
it "should not raise any errors" do
|
32
|
-
RestClient.
|
28
|
+
allow(RestClient).to receive(:post).and_return(200)
|
33
29
|
expect { subject.perform }.to_not raise_error
|
34
30
|
end
|
35
31
|
end
|
data/spec/lib/api_spec.rb
CHANGED
@@ -9,13 +9,13 @@ describe Vero::Api::Events do
|
|
9
9
|
expected = input.merge(:auth_token => "abc123", :development_mode => true)
|
10
10
|
|
11
11
|
mock_context = Vero::Context.new
|
12
|
-
mock_context.config.
|
13
|
-
mock_context.config.
|
14
|
-
mock_context.config.
|
12
|
+
allow(mock_context.config).to receive(:configured?).and_return(true)
|
13
|
+
allow(mock_context.config).to receive(:auth_token).and_return("abc123")
|
14
|
+
allow(mock_context.config).to receive(:development_mode).and_return(true)
|
15
15
|
|
16
|
-
Vero::App.
|
16
|
+
allow(Vero::App).to receive(:default_context).and_return(mock_context)
|
17
17
|
|
18
|
-
Vero::Sender.
|
18
|
+
expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Events::TrackAPI, true, "https://api.getvero.com", expected)
|
19
19
|
|
20
20
|
subject.track!(input)
|
21
21
|
end
|
@@ -23,76 +23,69 @@ describe Vero::Api::Events do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe Vero::Api::Users do
|
26
|
-
let
|
26
|
+
let(:subject) { Vero::Api::Users }
|
27
|
+
let(:mock_context) { Vero::Context.new }
|
28
|
+
let(:expected) { input.merge(:auth_token => "abc123", :development_mode => true) }
|
29
|
+
|
30
|
+
before :each do
|
31
|
+
allow(mock_context.config).to receive(:configured?).and_return(true)
|
32
|
+
allow(mock_context.config).to receive(:auth_token).and_return("abc123")
|
33
|
+
allow(mock_context.config).to receive(:development_mode).and_return(true)
|
34
|
+
allow(Vero::App).to receive(:default_context).and_return(mock_context)
|
35
|
+
end
|
27
36
|
|
28
37
|
describe :track! do
|
29
|
-
|
30
|
-
input
|
31
|
-
expected = input.merge(:auth_token => "abc123", :development_mode => true)
|
32
|
-
|
33
|
-
mock_context = Vero::Context.new
|
34
|
-
mock_context.config.stub(:configured?).and_return(true)
|
35
|
-
mock_context.config.stub(:auth_token).and_return("abc123")
|
36
|
-
mock_context.config.stub(:development_mode).and_return(true)
|
37
|
-
|
38
|
-
Vero::App.stub(:default_context).and_return(mock_context)
|
39
|
-
|
40
|
-
Vero::Sender.should_receive(:send).with(Vero::Api::Workers::Users::TrackAPI, true, "https://api.getvero.com", expected)
|
38
|
+
context "should call the TrackAPI object via the configured sender" do
|
39
|
+
let(:input) { {:email => "james@getvero.com", :data => {:age => 25}} }
|
41
40
|
|
42
|
-
|
41
|
+
specify do
|
42
|
+
expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::TrackAPI, true, "https://api.getvero.com", expected)
|
43
|
+
subject.track!(input)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
48
|
describe :edit_user! do
|
47
|
-
|
48
|
-
input
|
49
|
-
expected = input.merge(:auth_token => "abc123", :development_mode => true)
|
50
|
-
|
51
|
-
mock_context = Vero::Context.new
|
52
|
-
mock_context.config.stub(:configured?).and_return(true)
|
53
|
-
mock_context.config.stub(:auth_token).and_return("abc123")
|
54
|
-
mock_context.config.stub(:development_mode).and_return(true)
|
55
|
-
|
56
|
-
Vero::App.stub(:default_context).and_return(mock_context)
|
49
|
+
context "should call the TrackAPI object via the configured sender" do
|
50
|
+
let(:input) { {:email => "james@getvero.com", :changes => {:age => 25}} }
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
specify do
|
53
|
+
expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditAPI, true, "https://api.getvero.com", expected)
|
54
|
+
subject.edit_user!(input)
|
55
|
+
end
|
61
56
|
end
|
62
57
|
end
|
63
58
|
|
64
59
|
describe :edit_user_tags! do
|
65
|
-
|
66
|
-
input
|
67
|
-
expected = input.merge(:auth_token => "abc123", :development_mode => true)
|
68
|
-
|
69
|
-
mock_context = Vero::Context.new
|
70
|
-
mock_context.config.stub(:configured?).and_return(true)
|
71
|
-
mock_context.config.stub(:auth_token).and_return("abc123")
|
72
|
-
mock_context.config.stub(:development_mode).and_return(true)
|
73
|
-
|
74
|
-
Vero::App.stub(:default_context).and_return(mock_context)
|
60
|
+
context "should call the TrackAPI object via the configured sender" do
|
61
|
+
let(:input) { {:add => ["boom"], :remove => ["tish"]} }
|
75
62
|
|
76
|
-
|
77
|
-
|
78
|
-
|
63
|
+
specify do
|
64
|
+
expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::EditTagsAPI, true, "https://api.getvero.com", expected)
|
65
|
+
subject.edit_user_tags!(input)
|
66
|
+
end
|
79
67
|
end
|
80
68
|
end
|
81
69
|
|
82
70
|
describe :unsubscribe! do
|
83
|
-
|
84
|
-
input
|
85
|
-
expected = input.merge(:auth_token => "abc123", :development_mode => false)
|
86
|
-
|
87
|
-
mock_context = Vero::Context.new
|
88
|
-
mock_context.config.stub(:configured?).and_return(true)
|
89
|
-
mock_context.config.stub(:auth_token).and_return("abc123")
|
71
|
+
context "should call the TrackAPI object via the configured sender" do
|
72
|
+
let(:input) { {:email => "james@getvero"} }
|
90
73
|
|
91
|
-
|
74
|
+
specify do
|
75
|
+
expect(Vero::Sender).to receive(:send).with(Vero::Api::Workers::Users::UnsubscribeAPI, true, "https://api.getvero.com", expected)
|
76
|
+
subject.unsubscribe!(input)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
92
80
|
|
93
|
-
|
81
|
+
describe :resubscribe! do
|
82
|
+
context "should call the TrackAPI object via the configured sender" do
|
83
|
+
let(:input) { {:email => "james@getvero"} }
|
94
84
|
|
95
|
-
|
85
|
+
specify do
|
86
|
+
Vero::Sender.should_receive(:send).with(Vero::Api::Workers::Users::ResubscribeAPI, true, "https://api.getvero.com", expected)
|
87
|
+
subject.resubscribe!(input)
|
88
|
+
end
|
96
89
|
end
|
97
90
|
end
|
98
91
|
end
|
data/spec/lib/app_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Vero::App do
|
|
4
4
|
describe 'self.default_context' do
|
5
5
|
it "inherits from Vero::Context" do
|
6
6
|
actual = Vero::App.default_context
|
7
|
-
actual.
|
7
|
+
expect(actual).to be_a(Vero::Context)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -12,46 +12,46 @@ describe Vero::App do
|
|
12
12
|
describe :init do
|
13
13
|
it "should ignore configuring the config if no block is provided" do
|
14
14
|
Vero::App.init
|
15
|
-
context.configured
|
15
|
+
expect(context.configured?).to be(false)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should pass configuration defined in the block to the config file" do
|
19
19
|
Vero::App.init
|
20
20
|
|
21
|
-
context.config.api_key.
|
21
|
+
expect(context.config.api_key).to be_nil
|
22
22
|
Vero::App.init do |c|
|
23
23
|
c.api_key = "abcd1234"
|
24
24
|
end
|
25
|
-
context.config.api_key.
|
25
|
+
expect(context.config.api_key).to eq("abcd1234")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should init should be able to set async" do
|
29
29
|
Vero::App.init do |c|
|
30
30
|
c.async = false
|
31
31
|
end
|
32
|
-
context.config.async.
|
32
|
+
expect(context.config.async).to be(false)
|
33
33
|
|
34
34
|
Vero::App.init do |c|
|
35
35
|
c.async = true
|
36
36
|
end
|
37
|
-
context.config.async.
|
37
|
+
expect(context.config.async).to be(true)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe :disable_requests! do
|
42
42
|
it "should change config.disabled" do
|
43
43
|
Vero::App.init {}
|
44
|
-
context.config.disabled.
|
44
|
+
expect(context.config.disabled).to be(false)
|
45
45
|
|
46
46
|
Vero::App.disable_requests!
|
47
|
-
context.config.disabled.
|
47
|
+
expect(context.config.disabled).to be(true)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe :log do
|
52
52
|
it "should have a log method" do
|
53
53
|
Vero::App.init {}
|
54
|
-
Vero::App.
|
54
|
+
expect(Vero::App).to receive(:log)
|
55
55
|
Vero::App.log(Object, "test")
|
56
56
|
end
|
57
57
|
end
|