antwort 0.0.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +12 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +28 -1
- data/README.md +1 -1
- data/antwort.gemspec +2 -2
- data/lib/antwort.rb +5 -4
- data/lib/antwort/builder/builder.rb +15 -24
- data/lib/antwort/builder/email.rb +47 -22
- data/lib/antwort/builder/flattener.rb +8 -9
- data/lib/antwort/builder/partial.rb +12 -11
- data/lib/antwort/builder/style.rb +26 -27
- data/lib/antwort/{builder.rb → builders.rb} +3 -3
- data/lib/antwort/cli.rb +0 -1
- data/lib/antwort/cli/cli.rb +42 -48
- data/lib/antwort/cli/send.rb +11 -14
- data/lib/antwort/cli/upload.rb +29 -28
- data/lib/antwort/core.rb +4 -0
- data/lib/antwort/email/build.rb +41 -0
- data/lib/antwort/email/collection.rb +41 -0
- data/lib/antwort/email/data.rb +27 -0
- data/lib/antwort/email/template.rb +88 -0
- data/lib/antwort/helpers/file_helper.rb +27 -0
- data/lib/antwort/{helpers.rb → helpers/helper.rb} +2 -2
- data/lib/antwort/helpers/logic_helper.rb +81 -0
- data/lib/antwort/helpers/markup_helper.rb +37 -0
- data/lib/antwort/{builder/helpers/sanitizers.rb → helpers/sanitizers_helper.rb} +2 -4
- data/lib/antwort/helpers/server_helper.rb +32 -0
- data/lib/antwort/{server.rb → server/server.rb} +26 -23
- data/{template/project → lib/antwort/server}/views/404.html.erb +1 -1
- data/{template/project → lib/antwort/server}/views/index.html.erb +4 -6
- data/{template/project → lib/antwort/server}/views/layout.erb +5 -5
- data/{template/project/views/markup/_button.html.erb → lib/antwort/server/views/markup/button.html.erb} +0 -0
- data/{template/project/views/markup/_image_tag.html.erb → lib/antwort/server/views/markup/image_tag.html.erb} +0 -0
- data/{template/project → lib/antwort/server}/views/server.erb +0 -0
- data/lib/antwort/version.rb +1 -1
- data/spec/builder/builder_spec.rb +17 -22
- data/spec/builder/email_spec.rb +11 -12
- data/spec/builder/flattener_spec.rb +20 -21
- data/spec/builder/helpers_logic_spec.rb +69 -73
- data/spec/builder/partial_spec.rb +42 -51
- data/spec/builder/style_spec.rb +25 -34
- data/spec/{cli_spec.rb → cli/cli_spec.rb} +8 -9
- data/spec/cli/send_spec.rb +80 -0
- data/spec/cli/upload_spec.rb +17 -9
- data/spec/email/build_spec.rb +13 -0
- data/spec/email/collection_spec.rb +56 -0
- data/spec/email/data_spec.rb +40 -0
- data/spec/email/template_spec.rb +116 -0
- data/spec/fixtures/assets/css/demo/include.scss +3 -0
- data/spec/fixtures/assets/css/demo/inline.scss +33 -0
- data/spec/fixtures/assets/css/no-images/include.scss +1 -0
- data/spec/fixtures/assets/css/no-images/inline.scss +2 -0
- data/spec/fixtures/assets/css/shared/_base.scss +64 -0
- data/spec/fixtures/assets/css/shared/_mixins.scss +25 -0
- data/spec/fixtures/assets/css/shared/_reset.scss +59 -0
- data/spec/fixtures/assets/css/shared/_vars.scss +12 -0
- data/spec/fixtures/assets/css/shared/include.scss +23 -0
- data/spec/fixtures/assets/css/shared/inline.scss +9 -0
- data/spec/fixtures/build/demo-20160101/demo.html +177 -0
- data/spec/fixtures/build/demo-20160101/source/demo.html +118 -0
- data/spec/fixtures/build/demo-20160101/source/include.css +58 -0
- data/spec/fixtures/build/demo-20160101/source/inline.css +83 -0
- data/spec/fixtures/build/demo-20160102/demo.html +177 -0
- data/spec/fixtures/build/demo-20160102/source/demo.html +118 -0
- data/spec/fixtures/build/demo-20160102/source/include.css +58 -0
- data/spec/fixtures/build/demo-20160102/source/inline.css +83 -0
- data/{template/project/data/.empty_directory → spec/fixtures/emails/1-demo/_bar.erb} +0 -0
- data/spec/fixtures/emails/1-demo/_foo.erb +0 -0
- data/spec/fixtures/emails/1-demo/index.html.erb +2 -2
- data/spec/fixtures/emails/4-custom-layout/index.html.erb +6 -0
- data/spec/fixtures/emails/4-custom-layout/layout.erb +5 -0
- data/spec/fixtures/emails/demo/index.html.erb +4 -0
- data/spec/fixtures/emails/no-images/index.html.erb +4 -0
- data/spec/fixtures/emails/shared/_foo.erb +0 -0
- data/spec/fixtures/{views → emails/shared}/layout.erb +0 -0
- data/spec/helpers/file_helper_spec.rb +30 -0
- data/spec/server/server_spec.rb +57 -0
- data/spec/spec_helper.rb +18 -7
- data/template/project/Gemfile.tt +1 -7
- metadata +92 -42
- data/lib/antwort/builder/helpers/logic.rb +0 -82
- data/lib/antwort/cli/helpers.rb +0 -44
- data/lib/antwort/server/helpers.rb +0 -67
- data/lib/antwort/server/markup.rb +0 -39
- data/spec/cli/helpers_spec.rb +0 -60
- data/spec/fixtures/build/demo-123456/build.html +0 -7
- data/spec/fixtures/build/demo-123457/build.html +0 -7
- data/spec/fixtures/build/demo-bar-123/build.html +0 -7
- data/spec/fixtures/views/404.html.erb +0 -1
- data/spec/fixtures/views/index.html.erb +0 -14
- data/spec/fixtures/views/server.erb +0 -5
- data/spec/server_spec.rb +0 -54
- data/template/project/.ruby-version +0 -1
- data/template/project/data/config.yml +0 -3
@@ -1,87 +1,78 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Antwort::PartialBuilder do
|
4
|
+
let(:builder) { Antwort::PartialBuilder.new(email: '1-demo', id: '123', 'css-style': 'expanded') }
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
describe 'Builds' do
|
7
|
+
it 'builds HTML'
|
8
|
+
it 'inlines CSS'
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
it "builds HTML"
|
16
|
-
it "inlines CSS"
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "Helpers" do
|
20
|
-
describe "adjusts filename as necssary (make sure it ends with .html)" do
|
21
|
-
|
22
|
-
it "always starts with _" do
|
23
|
-
expect(@builder.adjust_filename('foo.erb')).to eq('_foo.html')
|
24
|
-
expect(@builder.adjust_filename('foo.html')).to eq('_foo.html')
|
25
|
-
expect(@builder.adjust_filename('foo.html.erb')).to eq('_foo.html')
|
11
|
+
describe 'Helpers' do
|
12
|
+
describe 'adjusts filename as necssary (make sure it ends with .html)' do
|
13
|
+
it 'always starts with _' do
|
14
|
+
expect(builder.adjust_filename('foo.erb')).to eq('_foo.html')
|
15
|
+
expect(builder.adjust_filename('foo.html')).to eq('_foo.html')
|
16
|
+
expect(builder.adjust_filename('foo.html.erb')).to eq('_foo.html')
|
26
17
|
end
|
27
18
|
|
28
|
-
it
|
29
|
-
expect(
|
30
|
-
expect(
|
31
|
-
expect(
|
19
|
+
it 'always ends with .html' do
|
20
|
+
expect(builder.adjust_filename('_foo.html.erb')).to eq('_foo.html')
|
21
|
+
expect(builder.adjust_filename('_foo.erb')).to eq('_foo.html')
|
22
|
+
expect(builder.adjust_filename('_foo.html')).to eq('_foo.html')
|
32
23
|
end
|
33
24
|
|
34
|
-
it
|
35
|
-
expect(
|
25
|
+
it 'uses template name instead of _index' do
|
26
|
+
expect(builder.adjust_filename('index.html.erb')).to eq('_1-demo.html')
|
36
27
|
end
|
37
28
|
end
|
38
29
|
|
39
|
-
describe
|
40
|
-
let
|
41
|
-
let
|
30
|
+
describe 'save from Nokogiri' do
|
31
|
+
let(:start) { '<div id="valid-dom-tree">' }
|
32
|
+
let(:ende) { '</div><!--/#valid-dom-tree-->' }
|
42
33
|
|
43
|
-
it
|
44
|
-
expect(
|
34
|
+
it 'can add nokogiri wrapper' do
|
35
|
+
expect(builder.send(:add_nokogiri_wrapper, 'foo')).to eq(start + 'foo' + ende)
|
45
36
|
end
|
46
37
|
|
47
|
-
it
|
48
|
-
expect(
|
49
|
-
expect(
|
50
|
-
expect(
|
38
|
+
it 'can remove nokogiri wrapper' do
|
39
|
+
expect(builder.send(:remove_nokogiri_wrapper, start + 'foo' + ende)).to eq('foo')
|
40
|
+
expect(builder.send(:remove_nokogiri_wrapper, start + 'foo' + '</div> <!--/#valid-dom-tree-->')).to eq('foo')
|
41
|
+
expect(builder.send(:remove_nokogiri_wrapper, start + 'foo' + "</div>\n<!--/#valid-dom-tree-->")).to eq('foo')
|
51
42
|
end
|
52
43
|
|
53
44
|
# TODO: These specs don't work because PartialBuilder cannot find matching CSS
|
54
45
|
|
55
|
-
it
|
56
|
-
|
57
|
-
expect(
|
46
|
+
it 'adds wrapper before inlining', skip: true do
|
47
|
+
builder.inline('foo')
|
48
|
+
expect(builder).to receive(:add_nokogiri_wrapper)
|
58
49
|
end
|
59
50
|
|
60
|
-
it
|
61
|
-
|
62
|
-
expect(
|
51
|
+
it 'removes wrapper after inlining', skip: true do
|
52
|
+
builder.inline('foo')
|
53
|
+
expect(builder).to receive(:remove_nokogiri_wrapper)
|
63
54
|
end
|
64
55
|
end
|
65
56
|
|
66
|
-
describe
|
67
|
-
it
|
57
|
+
describe 'Clean up' do
|
58
|
+
it 'can convert logic html entities back to operators' do
|
68
59
|
h = {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
60
|
+
'{% <= %}' => '{% <= %}', # only convert operators within logic
|
61
|
+
'{{ <= }}' => '{{ <= }}', # leave operators in content
|
62
|
+
'{% >= %}' => '{% >= %}',
|
63
|
+
'{{ >= }}' => '{{ >= }}',
|
64
|
+
' && ' => ' && '
|
74
65
|
}
|
75
66
|
h.each do |key, value|
|
76
|
-
expect(
|
67
|
+
expect(builder.cleanup_logic(key)).to eq(value)
|
77
68
|
end
|
78
69
|
end
|
79
70
|
|
80
|
-
it
|
71
|
+
it 'can restore variables in links' do
|
81
72
|
a = '<a href="%7B%7B%20hello%20%7D%7D">world</a>'
|
82
73
|
b = '<a href="{{ hello }}">world</a>'
|
83
|
-
expect(
|
74
|
+
expect(builder.restore_variables_in_links(a)).to eq(b)
|
84
75
|
end
|
85
76
|
end
|
86
77
|
end
|
87
|
-
end
|
78
|
+
end
|
data/spec/builder/style_spec.rb
CHANGED
@@ -1,66 +1,57 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Antwort::Style do
|
4
|
+
describe 'on Initialize' do
|
5
|
+
let(:style) { Antwort::Style.new('font-weight:bold;font-size:24px;line-height:28px;font-family:Helvetica, Arial, sans-serif;color:#111111;color:#2CA4D8') }
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
it "remembers all keys" do
|
9
|
-
expect(style.keys).to eq(['font-weight','font-size','line-height','font-family','color'])
|
7
|
+
it 'remembers all keys' do
|
8
|
+
expect(style.keys).to eq(['font-weight', 'font-size', 'line-height', 'font-family', 'color'])
|
10
9
|
end
|
11
|
-
it
|
10
|
+
it 'remembers duplicate keys' do
|
12
11
|
expect(style.duplicate_keys).to eq(['color'])
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
|
-
describe
|
17
|
-
let
|
15
|
+
describe 'Readable Attributes' do
|
16
|
+
let(:style) { Antwort::Style.new('font-size:24px;color:black;color:red') }
|
18
17
|
|
19
|
-
context
|
20
|
-
it
|
21
|
-
expect(style.original).to eq([{'font-size' => '24px'}, {'color'=>'black'}, {'color'=>'red'}])
|
18
|
+
context 'not flattened' do
|
19
|
+
it 'can be accessed as a hash' do
|
20
|
+
expect(style.original).to eq([{ 'font-size' => '24px' }, { 'color' => 'black' }, { 'color' => 'red' }])
|
22
21
|
end
|
23
|
-
it
|
22
|
+
it 'can be accessed as a string' do
|
24
23
|
expect(style.original_str).to eq('font-size:24px;color:black;color:red')
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
context
|
29
|
-
it
|
30
|
-
expect(style.flattened).to eq(
|
31
|
-
'font-size' => '24px',
|
32
|
-
'color' => 'red'
|
33
|
-
})
|
27
|
+
context 'flattened' do
|
28
|
+
it 'can be accessed as a hash' do
|
29
|
+
expect(style.flattened).to eq('font-size' => '24px', 'color' => 'red')
|
34
30
|
end
|
35
|
-
it
|
31
|
+
it 'can be accessed as a string' do
|
36
32
|
expect(style.flattened_str).to eq('font-size:24px;color:red')
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
|
-
it
|
36
|
+
it 'has a duplicates? method' do
|
41
37
|
expect(Antwort::Style.new('color:red;color:black').duplicates?).to eq(true)
|
42
38
|
expect(Antwort::Style.new('color:red;font-size:12px').duplicates?).to eq(false)
|
43
39
|
end
|
44
40
|
end
|
45
41
|
|
46
|
-
describe
|
47
|
-
it
|
48
|
-
style =
|
49
|
-
expect(style.flattened).to eq(
|
50
|
-
|
51
|
-
'border' => 'none'})
|
52
|
-
expect(style.flattened).not_to eq({
|
53
|
-
' color' => ' black',
|
54
|
-
'border ' => 'none'})
|
42
|
+
describe 'Code Formatting' do
|
43
|
+
it 'trims leading and trailing white space from styles' do
|
44
|
+
style = Antwort::Style.new('color:red; color: black;border :none;')
|
45
|
+
expect(style.flattened).to eq('color' => 'black', 'border' => 'none')
|
46
|
+
expect(style.flattened).not_to eq(' color' => ' black', 'border ' => 'none')
|
55
47
|
end
|
56
48
|
end
|
57
49
|
|
58
|
-
describe
|
59
|
-
it
|
50
|
+
describe 'Internal Helpers' do
|
51
|
+
it 'can push styles hash back into sting' do
|
60
52
|
hash = { 'font-size' => '14px', 'font-family' => 'Helvetica' }
|
61
53
|
style = Antwort::Style.new
|
62
54
|
expect(style.send(:hash_to_str, hash)).to eq('font-size:14px;font-family:Helvetica')
|
63
55
|
end
|
64
56
|
end
|
65
|
-
|
66
|
-
end
|
57
|
+
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Antwort::CLI do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
Dir.chdir(fixtures_root)
|
7
|
-
end
|
8
|
-
|
9
4
|
describe '#upload' do
|
10
|
-
|
5
|
+
before :all do
|
6
|
+
Fog.mock!
|
7
|
+
end
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
after :all do
|
10
|
+
Fog.unmock!
|
14
11
|
end
|
15
12
|
|
16
|
-
|
13
|
+
let(:output) { capture(:stdout) { subject.upload('1-demo') } }
|
14
|
+
|
15
|
+
context 'user confirms upload', skip: true do
|
17
16
|
before :each do
|
18
17
|
allow_any_instance_of(Thor::Actions).to receive(:yes?).and_return(true)
|
19
18
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Antwort::CLI::Send do
|
4
|
+
after :each do
|
5
|
+
Mail::TestMailer.deliveries.clear
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'Send' do
|
9
|
+
it 'can send emails' do
|
10
|
+
Antwort::CLI::Send.new('demo-20160101').send
|
11
|
+
expect(Mail::TestMailer.deliveries.length).to eq(1)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'Defaults' do
|
16
|
+
before :each do
|
17
|
+
@a = Antwort::CLI::Send.new('demo-20160101')
|
18
|
+
@a.send
|
19
|
+
@sent = Mail::TestMailer.deliveries.last
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has a default text body' do
|
23
|
+
expect(@sent.text_part.body).to eq('This is plain text')
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'set by environment variables' do
|
27
|
+
it 'from' do
|
28
|
+
expect(@sent.from.length).to eq(1)
|
29
|
+
expect(@sent.from.first).to eq('TEST_ENV_SEND_FROM')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'to' do
|
33
|
+
expect(@sent.to.length).to eq(1)
|
34
|
+
expect(@sent.to.first).to eq('TEST_ENV_SEND_TO')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "uses to build <title> prefixed with '[Test] '" do
|
39
|
+
expect(@sent.subject).to eq('[Test] Fixture Demo')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has an HTML body, that is pulled from build index.html' do
|
43
|
+
# comes back as empty string in testing?
|
44
|
+
# expect(@sent.html_part.body.to_s).not_to eq ''
|
45
|
+
# puts @sent.to_s.inspect
|
46
|
+
|
47
|
+
contents = File.open('build/demo-20160101/demo.html').read
|
48
|
+
expect(@a.html_body).to eq(contents)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'Optional Arguments' do
|
53
|
+
before :each do
|
54
|
+
Antwort::CLI::Send.new(
|
55
|
+
'demo-20160101',
|
56
|
+
from: 'CUSTOM_FROM',
|
57
|
+
recipient: 'CUSTOM_TO',
|
58
|
+
subject: 'MY SUBJECT'
|
59
|
+
).send
|
60
|
+
@sent = Mail::TestMailer.deliveries.last
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts a sender argument' do
|
64
|
+
expect(@sent.from.first).to eq('CUSTOM_FROM')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'accepts one recipient' do
|
68
|
+
expect(@sent.to).to include('CUSTOM_TO')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'accepts multiple recipients' do
|
72
|
+
Antwort::CLI::Send.new('demo-20160101', recipient: 'one, two').send
|
73
|
+
expect(Mail::TestMailer.deliveries.last.to).to eq(%w(one two))
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'accepts a title argument' do
|
77
|
+
expect(@sent.subject).to eq('MY SUBJECT')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/cli/upload_spec.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Antwort::CLI::Upload do
|
4
|
-
|
5
|
-
subject { described_class.new('newsletter') }
|
4
|
+
subject { Antwort::CLI::Upload.new('1-demo') }
|
6
5
|
|
7
6
|
before :all do
|
8
|
-
|
7
|
+
Fog.mock!
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
Fog.mock!
|
14
|
-
allow_any_instance_of(Thor::Actions).to receive(:yes?).and_return(true)
|
10
|
+
after :all do
|
11
|
+
Fog.unmock!
|
15
12
|
end
|
16
13
|
|
17
|
-
|
14
|
+
before :each do
|
15
|
+
allow_any_instance_of(Thor::Actions).to receive(:yes?).and_return(true)
|
16
|
+
end
|
18
17
|
|
19
18
|
describe '#upload' do
|
20
19
|
before :each do
|
21
20
|
allow(Dir).to receive(:foreach)
|
22
21
|
end
|
23
22
|
|
24
|
-
|
23
|
+
xit 'cleans S3 directory before upload' do
|
25
24
|
expect(subject).to receive(:clean_directory!)
|
26
25
|
subject.upload
|
27
26
|
end
|
@@ -44,4 +43,13 @@ describe Antwort::CLI::Upload do
|
|
44
43
|
expect(subject).to respond_to(:clean_directory!)
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
|
+
describe('#upload_path') do
|
48
|
+
it 'retuns AWS path (excludes assets/images)' do
|
49
|
+
expect(subject.upload_path('foo.png')).to eq('1-demo/foo.png')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'uploads files to AWS'
|
54
|
+
it 'allows user to abort upload'
|
47
55
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Antwort::EmailCollection do
|
4
|
+
let(:collection) { Antwort::EmailCollection.new }
|
5
|
+
let(:fixtures_email_list) { ['1-demo', '2-no-layout', '3-no-title', '4-custom-layout', 'demo', 'no-images'] }
|
6
|
+
|
7
|
+
describe 'has a templates attribute' do
|
8
|
+
it 'is an array' do
|
9
|
+
expect(collection.templates).to be_kind_of(Array)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'holds EmailTemplates' do
|
13
|
+
expect(collection.templates.first).to be_kind_of(Antwort::EmailTemplate)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'loads emails by directory names' do
|
17
|
+
result = fixtures_email_list
|
18
|
+
expect(collection.list).to eq(result)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'filters' do
|
22
|
+
it 'excludes non-email folders' do
|
23
|
+
expect(collection.list).not_to include('.')
|
24
|
+
expect(collection.list).not_to include('..')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'excludes the shared folder' do
|
28
|
+
expect(collection.list).not_to include('shared')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'API' do
|
33
|
+
describe '`#empty?`' do
|
34
|
+
context 'has templates' do
|
35
|
+
it 'returns false' do
|
36
|
+
expect(collection.empty?).to be false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context 'has no templates' do
|
40
|
+
it 'returns true' do
|
41
|
+
Dir.chdir("#{fixtures_root}/emails")
|
42
|
+
c = Antwort::EmailCollection.new
|
43
|
+
expect(c.empty?).to be true
|
44
|
+
|
45
|
+
# Go back or randomized specs fail
|
46
|
+
Dir.chdir(fixtures_root)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#total' do
|
52
|
+
expect(collection.total).to eq fixtures_email_list.length
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|