emarsys-broadcast 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -3
- data/README.md +16 -8
- data/emarsys-broadcast.gemspec +8 -4
- data/lib/emarsys/broadcast/api.rb +2 -3
- data/lib/emarsys/broadcast/batch.rb +12 -6
- data/lib/emarsys/broadcast/http.rb +0 -1
- data/lib/emarsys/broadcast/version.rb +1 -1
- data/spec/api_spec.rb +145 -10
- data/spec/email_spec.rb +3 -3
- data/spec/fixtures/responses/ok.http +8 -0
- data/spec/fixtures/responses/senders_200_two_senders.http +19 -0
- data/spec/fixtures/{minimal_batch.xml → xml/minimal_batch.xml} +0 -0
- data/spec/fixtures/{minimal_escaped_batch.xml → xml/minimal_escaped_batch.xml} +0 -0
- data/spec/fixtures/{xml_builder_import.xml → xml/xml_builder_import.xml} +0 -0
- data/spec/sftp_spec.rb +4 -4
- data/spec/spec_helper.rb +21 -13
- data/spec/validation_spec.rb +7 -7
- metadata +43 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f9c2e6602550a3c67a2687c65122e97095681ca
|
4
|
+
data.tar.gz: 7c138892b238c4a6451d0c3dc9023383c3ad0778
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a4060e35b1e8ec27fc4706d4fe67c2cd65599c0f08d4fd9fbdc185a7fd0c1b24d829eb3441544d5a81c8fe90b77bd17df7de05f86abca255946fec4d5475d27
|
7
|
+
data.tar.gz: 572c2d62622fccff31fafc740cfd154c54c6d48a68769aca68e090228582939d0c72613636a4f1a44da5f2e70d8a04ae01747de7a44a498302185d75e9b41c87
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<p align="center">
|
2
|
+
<h2>Emarsys::Broadcast</h2>
|
3
|
+
<h3>Ruby library for Emarsys batch mailing API</h3>
|
4
|
+
<br/>
|
5
|
+
<br/>
|
6
|
+
<a href="https://travis-ci.org/Valve/emarsys-broadcast-ruby">
|
7
|
+
<img src="http://img.shields.io/travis/Valve/emarsys-broadcast-ruby/master.svg?style=flat" />
|
8
|
+
</a>
|
9
|
+
<a href="https://codeclimate.com/github/Valve/emarsys-broadcast-ruby">
|
10
|
+
<img src="http://img.shields.io/codeclimate/github/Valve/emarsys-broadcast-ruby.svg?style=flat" />
|
11
|
+
</a>
|
12
|
+
</p>
|
5
13
|
|
6
14
|
## Installation
|
7
15
|
|
@@ -38,11 +46,11 @@ end
|
|
38
46
|
|
39
47
|
# create a batch that you want to send
|
40
48
|
batch = Emarsys::Broadcast::Batch.new
|
41
|
-
batch.sender = '
|
49
|
+
batch.sender = 'news@company.com'
|
42
50
|
batch.name = 'newsletter_2013_06_01'
|
43
51
|
batch.subject = 'June 2013 company news'
|
44
52
|
batch.body_html = '<h1>Dear 朋友!</h1>'
|
45
|
-
batch.recipients_path = '/path/to/your/csv/with/emails'
|
53
|
+
batch.recipients_path = '/path/to/your/csv/with/emails.csv'
|
46
54
|
|
47
55
|
# create API client
|
48
56
|
api = Emarsys::Broadcast::API.new
|
@@ -79,7 +87,7 @@ Valid email, registed with Emarsys.
|
|
79
87
|
|
80
88
|
Emarsys maintains a list of allowed sender emails, and restricts
|
81
89
|
sending emails from arbitrary email. If you want to use an email as a
|
82
|
-
sender, refer to
|
90
|
+
sender, refer to [working with senders](#working-with-senders)
|
83
91
|
|
84
92
|
_Can be set once via configuration_
|
85
93
|
|
@@ -152,7 +160,7 @@ batch.body_html = '<h1>Dear 朋友!</h1>'
|
|
152
160
|
* sender (required attribute)
|
153
161
|
* sender_domain (required attribute)
|
154
162
|
* recipients_path (required attribute)
|
155
|
-
* import_delay_hours (optional attribute) see more [here](#
|
163
|
+
* import_delay_hours (optional attribute) see more [here](#batchimport_delay_hours)
|
156
164
|
|
157
165
|
|
158
166
|
### Batch validation
|
data/emarsys-broadcast.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "emarsys-broadcast"
|
8
8
|
spec.version = Emarsys::Broadcast::VERSION
|
9
9
|
spec.authors = ["Valentin Vasilyev"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["valentin.vasilyev@outlook.com"]
|
11
11
|
spec.description = %q{Emarsys broadcast API for Ruby}
|
12
12
|
spec.summary = %q{Emarsys broadcast API for Ruby}
|
13
13
|
spec.homepage = "https://github.com/Valve/emarsys-broadcast-ruby"
|
@@ -20,11 +20,15 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "net-sftp"
|
22
22
|
spec.add_dependency "nokogiri"
|
23
|
-
spec.add_dependency "activemodel", "~>
|
23
|
+
spec.add_dependency "activemodel", "~> 4.0"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
28
|
spec.add_development_dependency "timecop"
|
29
29
|
spec.add_development_dependency "webmock"
|
30
|
+
# when specs fail for some reason
|
31
|
+
# spec.add_development_dependency "pry"
|
32
|
+
# spec.add_development_dependency "pry-debugger"
|
33
|
+
# spec.add_development_dependency "plymouth"
|
30
34
|
end
|
@@ -70,10 +70,9 @@ module Emarsys
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def validate_sender(email)
|
73
|
-
msg =
|
74
|
-
raise ValidationError
|
73
|
+
msg = "Email `#{email}` is not registered with Emarsys as a sender, register it with `create_sender` api call"
|
74
|
+
raise ValidationError.new(msg, [msg]) unless sender_exists? email
|
75
75
|
end
|
76
76
|
end
|
77
|
-
class ApiError < StandardError; end
|
78
77
|
end
|
79
78
|
end
|
@@ -4,7 +4,7 @@ module Emarsys
|
|
4
4
|
class Batch
|
5
5
|
include ActiveModel::Validations
|
6
6
|
attr_accessor \
|
7
|
-
:name,
|
7
|
+
:name,
|
8
8
|
:subject,
|
9
9
|
:body_html,
|
10
10
|
:recipients_path,
|
@@ -15,11 +15,17 @@ module Emarsys
|
|
15
15
|
:sender_id,
|
16
16
|
:import_delay_hours
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
validates :name, :subject, :body_html, :recipients_path, :sender, :sender_domain, presence: true
|
19
|
+
validates :name, format: { with: /\A[a-z]\w*\z/i, message: 'must start with a letter and contain only letters, numbers and underscores' }
|
20
|
+
validates :subject, length: { maximum: 255 }
|
21
|
+
validates :sender, format: { with: /@/, message: 'is not a valid email' }
|
22
|
+
validates :sender_domain, format: { with: URI::REL_URI, message: 'is not valid' }
|
23
|
+
|
24
|
+
def initialize(attributes = {})
|
25
|
+
attributes.each do |name, value|
|
26
|
+
send("#{name}=", value)
|
27
|
+
end
|
28
|
+
end
|
23
29
|
|
24
30
|
end
|
25
31
|
end
|
data/spec/api_spec.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Emarsys::Broadcast::API do
|
4
|
-
before(:each)
|
5
|
-
|
4
|
+
before(:each) do
|
5
|
+
create_valid_config
|
6
|
+
stub_senders_ok_two_senders
|
7
|
+
end
|
6
8
|
let(:config){create_valid_config}
|
9
|
+
|
7
10
|
describe 'initialize' do
|
8
11
|
context 'when configured properly' do
|
9
12
|
|
@@ -13,26 +16,158 @@ describe Emarsys::Broadcast::API do
|
|
13
16
|
end
|
14
17
|
|
15
18
|
it 'should instantiate sftp' do
|
16
|
-
Emarsys::Broadcast::SFTP.
|
17
|
-
|
19
|
+
expect(Emarsys::Broadcast::SFTP).to receive(:new).with(config)
|
20
|
+
Emarsys::Broadcast::API.new
|
18
21
|
end
|
19
22
|
|
20
23
|
it 'should instantiate http' do
|
21
|
-
Emarsys::Broadcast::HTTP.
|
22
|
-
|
24
|
+
expect(Emarsys::Broadcast::HTTP).to receive(:new).with(config)
|
25
|
+
Emarsys::Broadcast::API.new
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
describe '#send_batch' do
|
28
|
-
|
29
|
-
let(:
|
31
|
+
|
32
|
+
let(:batch){create_minimal_batch}
|
33
|
+
let(:api) do
|
34
|
+
api = Emarsys::Broadcast::API.new
|
35
|
+
allow(api).to receive(:upload_recipients){true}
|
36
|
+
api
|
37
|
+
end
|
38
|
+
before{stub_post_ok}
|
39
|
+
|
30
40
|
|
31
41
|
it 'should raise ValidationError if passed invalid batch' do
|
32
42
|
expect {
|
33
43
|
invalid_batch = Emarsys::Broadcast::Batch.new
|
34
|
-
api.send_batch
|
44
|
+
api.send_batch invalid_batch
|
45
|
+
}.to raise_error Emarsys::Broadcast::ValidationError
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should raise ValidationError if such sender does not exist' do
|
49
|
+
valid_batch = create_minimal_batch
|
50
|
+
valid_batch.sender = 'nonexistent@sender.com'
|
51
|
+
expect{
|
52
|
+
api.send_batch valid_batch
|
35
53
|
}.to raise_error Emarsys::Broadcast::ValidationError
|
36
54
|
end
|
55
|
+
|
56
|
+
it 'should post to batch creation Emarsys URL given a valid batch' do
|
57
|
+
api.send_batch(batch)
|
58
|
+
expect(WebMock).to have_requested(:post, 'https://a:a@e3.emarsys.net/bmapi/v2/batches/batch_name')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should post to batch import Emarsys URL given a valid batch' do
|
62
|
+
api.send_batch(batch)
|
63
|
+
expect(WebMock).to have_requested(:post, 'https://a:a@e3.emarsys.net/bmapi/v2/batches/batch_name/import')
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'batch supplementation from config' do
|
67
|
+
|
68
|
+
describe 'recipients_path' do
|
69
|
+
before(:each)do
|
70
|
+
create_valid_config
|
71
|
+
Emarsys::Broadcast.configuration.recipients_path = '/path/from/configuration'
|
72
|
+
end
|
73
|
+
it 'is in config but not in batch, batch should be updated with recipients_path from config' do
|
74
|
+
batch.recipients_path = nil
|
75
|
+
api.send_batch batch
|
76
|
+
expect(batch.recipients_path).to eq '/path/from/configuration'
|
77
|
+
end
|
78
|
+
it 'is in config and in batch, batch should not be updated with recipients_path from config' do
|
79
|
+
batch.recipients_path = '/path/from/batch'
|
80
|
+
api.send_batch batch
|
81
|
+
expect(batch.recipients_path).to eq '/path/from/batch'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'sender' do
|
86
|
+
before(:each) do
|
87
|
+
create_valid_config
|
88
|
+
Emarsys::Broadcast.configuration.sender = 'sender1@example.com'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'is in config but not in batch, batch should be updated with sender from config' do
|
92
|
+
batch.sender = nil
|
93
|
+
api.send_batch batch
|
94
|
+
expect(batch.sender).to eq 'sender1@example.com'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'is in config and in batch, batch should not be updated with sender from config' do
|
98
|
+
batch.sender = 'sender2@example.com'
|
99
|
+
api.send_batch batch
|
100
|
+
expect(batch.sender).to eq 'sender2@example.com'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'sender_domain' do
|
105
|
+
before(:each) do
|
106
|
+
create_valid_config
|
107
|
+
Emarsys::Broadcast.configuration.sender_domain = 'configuration.com'
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'is in config but not in batch, batch should be updated with sender_domain from config' do
|
111
|
+
batch.sender_domain = nil
|
112
|
+
api.send_batch batch
|
113
|
+
expect(batch.sender_domain).to eq 'configuration.com'
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'is in config and in batch, batch should not be updated with sender_domain from config' do
|
117
|
+
batch.sender_domain = 'batch.com'
|
118
|
+
api.send_batch batch
|
119
|
+
expect(batch.sender_domain).to eq 'batch.com'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'import_delay_hours' do
|
124
|
+
before(:each) do
|
125
|
+
create_valid_config
|
126
|
+
Emarsys::Broadcast.configuration.import_delay_hours = 23
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'is in config but not in batch, batch should be updated with import_delay_hours from config' do
|
130
|
+
batch.import_delay_hours = nil
|
131
|
+
api.send_batch batch
|
132
|
+
expect(batch.import_delay_hours).to eq 23
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'is in config and in batch, batch should not be updated with import_delay_hours from config' do
|
136
|
+
batch.import_delay_hours = 17
|
137
|
+
api.send_batch batch
|
138
|
+
expect(batch.import_delay_hours).to eq 17
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'send_time' do
|
143
|
+
it 'is not in batch, batch should be scheduled for current time' do
|
144
|
+
Timecop.freeze(spec_time) do
|
145
|
+
batch.send_time = nil
|
146
|
+
api.send_batch batch
|
147
|
+
expect(batch.send_time).to eq spec_time
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'is set in batch, batch should not be scheduled for current time' do
|
152
|
+
Timecop.freeze(spec_time) do
|
153
|
+
batch.send_time = Time.now + 30_000
|
154
|
+
api.send_batch batch
|
155
|
+
expect(batch.send_time).not_to eq spec_time
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#get_senders' do
|
163
|
+
let(:api){Emarsys::Broadcast::API.new}
|
164
|
+
it 'should call Emarsys URL for getting senders via GET' do
|
165
|
+
api.get_senders
|
166
|
+
expect(WebMock).to have_requested(:get, 'https://a:a@e3.emarsys.net/bmapi/v2/senders')
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should return an array of senders' do
|
170
|
+
expect(api.get_senders).to be_a Array
|
171
|
+
end
|
37
172
|
end
|
38
|
-
end
|
173
|
+
end
|
data/spec/email_spec.rb
CHANGED
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Emarsys::Broadcast::Email do
|
4
4
|
it 'should validate valid email' do
|
5
|
-
expect(Emarsys::Broadcast::Email::validate 'winston.smith-1984@big.brother.ru').to
|
6
|
-
expect(Emarsys::Broadcast::Email::validate 'abc@example.com').to
|
5
|
+
expect(Emarsys::Broadcast::Email::validate 'winston.smith-1984@big.brother.ru').to be_truthy
|
6
|
+
expect(Emarsys::Broadcast::Email::validate 'abc@example.com').to be_truthy
|
7
7
|
end
|
8
8
|
it 'should not validate invalid email' do
|
9
|
-
expect(Emarsys::Broadcast::Email::validate 'some invalid@email').to
|
9
|
+
expect(Emarsys::Broadcast::Email::validate 'some invalid@email').to be_falsey
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Thu, 18 Apr 2013 09:45:50 GMT
|
3
|
+
Server: Noelios-Restlet-Engine/1.1.10
|
4
|
+
Content-Type: application/xml; charset=UTF-8
|
5
|
+
Content-Length: 3376
|
6
|
+
Vary: Accept-Charset,Accept-Encoding,Accept-Language,Accept
|
7
|
+
Accept-Ranges: bytes
|
8
|
+
Via: 1.1 e3.emarsys.net
|
9
|
+
|
10
|
+
<?xml version='1.0' encoding='utf-8'?>
|
11
|
+
<senders>
|
12
|
+
<sender id="sender_id_1">
|
13
|
+
<name>Sender 1</name>
|
14
|
+
<address>sender1@example.com</address>
|
15
|
+
</sender><sender id="sender_id_2">
|
16
|
+
<name>Sender 2</name>
|
17
|
+
<address>sender2@example.com</address>
|
18
|
+
</sender>
|
19
|
+
</senders>
|
File without changes
|
File without changes
|
File without changes
|
data/spec/sftp_spec.rb
CHANGED
@@ -84,14 +84,14 @@ describe Emarsys::Broadcast::SFTP do
|
|
84
84
|
|
85
85
|
describe '#upload_file' do
|
86
86
|
it 'should call Net::SFTP.start with sftp configuration values' do
|
87
|
-
Net::SFTP.
|
87
|
+
expect(Net::SFTP).to receive(:start).with(config.sftp_host, config.sftp_user, password: config.sftp_password)
|
88
88
|
sftp.upload_file('local_file', 'remote_file')
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should take an instance of SFTP as a block argument and call #upload! on it with file paths' do
|
92
|
-
mock_session =
|
93
|
-
Net::SFTP.
|
94
|
-
mock_session.
|
92
|
+
mock_session = double('session')
|
93
|
+
allow(Net::SFTP).to receive(:start).and_yield mock_session
|
94
|
+
expect(mock_session).to receive(:upload!).with('local_file', 'remote_file')
|
95
95
|
sftp.upload_file('local_file', 'remote_file')
|
96
96
|
end
|
97
97
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'emarsys/broadcast'
|
4
4
|
require 'timecop'
|
5
|
+
require 'webmock/rspec'
|
5
6
|
|
6
7
|
|
7
8
|
def restore_default_config
|
@@ -19,27 +20,17 @@ def create_valid_config
|
|
19
20
|
c.api_password = 'a'
|
20
21
|
|
21
22
|
c.sender = spec_sender
|
23
|
+
c.recipients_path = '/some/path.csv'
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
def create_full_batch
|
26
|
-
batch = Emarsys::Broadcast::Batch.new
|
27
|
-
batch.name="test_batch_#{Time.now.to_i}"
|
28
|
-
batch.subject = 'די שטאַט פון ישראל'
|
29
|
-
batch.body_html = '<h1>די שטאט ווערט שוין דערמאנט אין תנ"ך. לויט געוויסע איז אליעזר (עבד אברהם) פון דמשק. דוד המלך, האט מלחמה געהאלטן און איינגענומען דמשק. און שפעטער מלכי ישראל. דאס איז שוין 3,000 יאר צוריק.<i>!</i></h1>'
|
30
|
-
batch.sender = 'פייַןבאָכער@gmail.com'
|
31
|
-
batch.sender_domain = 'google.com'
|
32
|
-
batch.send_time = Time.now + 1000000
|
33
|
-
batch
|
34
|
-
end
|
35
|
-
|
36
27
|
def create_minimal_batch
|
37
28
|
batch = Emarsys::Broadcast::Batch.new
|
38
29
|
batch.name="batch_name"
|
39
30
|
batch.subject = 'subject'
|
40
31
|
batch.body_html = 'body'
|
41
32
|
batch.send_time = spec_time
|
42
|
-
batch.
|
33
|
+
batch.sender = 'sender1@example.com'
|
43
34
|
batch.sender_domain = 'e3.emarsys.net'
|
44
35
|
batch
|
45
36
|
end
|
@@ -50,7 +41,7 @@ def create_minimal_html_batch
|
|
50
41
|
batch.subject = 'subject'
|
51
42
|
batch.body_html = '<h1>hello</h1>'
|
52
43
|
batch.send_time = spec_time
|
53
|
-
batch.
|
44
|
+
batch.sender = 'sender1@example.com'
|
54
45
|
batch.sender_domain = 'e3.emarsys.net'
|
55
46
|
batch
|
56
47
|
end
|
@@ -63,3 +54,20 @@ def spec_sender
|
|
63
54
|
'abc@example.com'
|
64
55
|
end
|
65
56
|
|
57
|
+
def stub_senders_ok_two_senders(senders = [])
|
58
|
+
fixture_path = File.dirname(__FILE__) + '/fixtures/responses/senders_200_two_senders.http'
|
59
|
+
stub_request(:get, "https://a:a@e3.emarsys.net/bmapi/v2/senders")
|
60
|
+
.with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/xml', 'User-Agent'=>'Ruby'})
|
61
|
+
.to_return(File.new fixture_path)
|
62
|
+
end
|
63
|
+
|
64
|
+
def stub_post_ok
|
65
|
+
fixture_path = File.dirname(__FILE__) + '/fixtures/responses/ok.http'
|
66
|
+
stub_request(:post, %r{https://a:a@e3.emarsys.net/bmapi/v2/.*}).to_return(http_ok)
|
67
|
+
end
|
68
|
+
|
69
|
+
def http_ok
|
70
|
+
fixture_path = File.dirname(__FILE__) + '/fixtures/responses/ok.http'
|
71
|
+
File.new fixture_path
|
72
|
+
end
|
73
|
+
|
data/spec/validation_spec.rb
CHANGED
@@ -8,33 +8,33 @@ describe Emarsys::Broadcast::Validation do
|
|
8
8
|
describe '#string_present?' do
|
9
9
|
|
10
10
|
it 'should return true if string not nil or empty' do
|
11
|
-
expect(test.string_present? 'hello').to
|
11
|
+
expect(test.string_present? 'hello').to be_truthy
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should return false if string is nil' do
|
15
|
-
expect(test.string_present? nil).to
|
15
|
+
expect(test.string_present? nil).to be_falsey
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should return false if string is empty' do
|
19
|
-
expect(test.string_present? '').to
|
19
|
+
expect(test.string_present? '').to be_falsey
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should return false if string is all spaces' do
|
23
|
-
expect(test.string_present? ' ').to
|
23
|
+
expect(test.string_present? ' ').to be_falsey
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#within_range?' do
|
28
28
|
it 'should return true if integer is within range' do
|
29
|
-
expect(test.within_range? 99, 1..100).to
|
29
|
+
expect(test.within_range? 99, 1..100).to be_truthy
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should return false if integer is not within range' do
|
33
|
-
expect(test.within_range? 101, 1..100).to
|
33
|
+
expect(test.within_range? 101, 1..100).to be_falsey
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should return false if integer is nil' do
|
37
|
-
expect(test.within_range? nil, 1..100).to
|
37
|
+
expect(test.within_range? nil, 1..100).to be_falsey
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should raise ArgumentError is range is nil' do
|
metadata
CHANGED
@@ -1,154 +1,137 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emarsys-broadcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Valentin Vasilyev
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: net-sftp
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: nokogiri
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activemodel
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '4.0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '4.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
61
|
+
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
68
|
+
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
89
|
+
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
96
|
+
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: timecop
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: webmock
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: Emarsys broadcast API for Ruby
|
143
126
|
email:
|
144
|
-
-
|
127
|
+
- valentin.vasilyev@outlook.com
|
145
128
|
executables: []
|
146
129
|
extensions: []
|
147
130
|
extra_rdoc_files: []
|
148
131
|
files:
|
149
|
-
- .gitignore
|
150
|
-
- .rspec
|
151
|
-
- .travis.yml
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
152
135
|
- Gemfile
|
153
136
|
- LICENSE.txt
|
154
137
|
- README.md
|
@@ -172,9 +155,11 @@ files:
|
|
172
155
|
- spec/batch_xml_builder_spec.rb
|
173
156
|
- spec/configuration_spec.rb
|
174
157
|
- spec/email_spec.rb
|
175
|
-
- spec/fixtures/
|
176
|
-
- spec/fixtures/
|
177
|
-
- spec/fixtures/
|
158
|
+
- spec/fixtures/responses/ok.http
|
159
|
+
- spec/fixtures/responses/senders_200_two_senders.http
|
160
|
+
- spec/fixtures/xml/minimal_batch.xml
|
161
|
+
- spec/fixtures/xml/minimal_escaped_batch.xml
|
162
|
+
- spec/fixtures/xml/xml_builder_import.xml
|
178
163
|
- spec/http_spec.rb
|
179
164
|
- spec/sftp_spec.rb
|
180
165
|
- spec/spec_helper.rb
|
@@ -184,27 +169,26 @@ files:
|
|
184
169
|
homepage: https://github.com/Valve/emarsys-broadcast-ruby
|
185
170
|
licenses:
|
186
171
|
- MIT
|
172
|
+
metadata: {}
|
187
173
|
post_install_message:
|
188
174
|
rdoc_options: []
|
189
175
|
require_paths:
|
190
176
|
- lib
|
191
177
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
178
|
requirements:
|
194
|
-
- -
|
179
|
+
- - ">="
|
195
180
|
- !ruby/object:Gem::Version
|
196
181
|
version: '0'
|
197
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
-
none: false
|
199
183
|
requirements:
|
200
|
-
- -
|
184
|
+
- - ">="
|
201
185
|
- !ruby/object:Gem::Version
|
202
186
|
version: '0'
|
203
187
|
requirements: []
|
204
188
|
rubyforge_project:
|
205
|
-
rubygems_version:
|
189
|
+
rubygems_version: 2.3.0
|
206
190
|
signing_key:
|
207
|
-
specification_version:
|
191
|
+
specification_version: 4
|
208
192
|
summary: Emarsys broadcast API for Ruby
|
209
193
|
test_files:
|
210
194
|
- spec/api_spec.rb
|
@@ -212,9 +196,11 @@ test_files:
|
|
212
196
|
- spec/batch_xml_builder_spec.rb
|
213
197
|
- spec/configuration_spec.rb
|
214
198
|
- spec/email_spec.rb
|
215
|
-
- spec/fixtures/
|
216
|
-
- spec/fixtures/
|
217
|
-
- spec/fixtures/
|
199
|
+
- spec/fixtures/responses/ok.http
|
200
|
+
- spec/fixtures/responses/senders_200_two_senders.http
|
201
|
+
- spec/fixtures/xml/minimal_batch.xml
|
202
|
+
- spec/fixtures/xml/minimal_escaped_batch.xml
|
203
|
+
- spec/fixtures/xml/xml_builder_import.xml
|
218
204
|
- spec/http_spec.rb
|
219
205
|
- spec/sftp_spec.rb
|
220
206
|
- spec/spec_helper.rb
|