antwort 0.0.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +12 -0
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +28 -1
  6. data/README.md +1 -1
  7. data/antwort.gemspec +2 -2
  8. data/lib/antwort.rb +5 -4
  9. data/lib/antwort/builder/builder.rb +15 -24
  10. data/lib/antwort/builder/email.rb +47 -22
  11. data/lib/antwort/builder/flattener.rb +8 -9
  12. data/lib/antwort/builder/partial.rb +12 -11
  13. data/lib/antwort/builder/style.rb +26 -27
  14. data/lib/antwort/{builder.rb → builders.rb} +3 -3
  15. data/lib/antwort/cli.rb +0 -1
  16. data/lib/antwort/cli/cli.rb +42 -48
  17. data/lib/antwort/cli/send.rb +11 -14
  18. data/lib/antwort/cli/upload.rb +29 -28
  19. data/lib/antwort/core.rb +4 -0
  20. data/lib/antwort/email/build.rb +41 -0
  21. data/lib/antwort/email/collection.rb +41 -0
  22. data/lib/antwort/email/data.rb +27 -0
  23. data/lib/antwort/email/template.rb +88 -0
  24. data/lib/antwort/helpers/file_helper.rb +27 -0
  25. data/lib/antwort/{helpers.rb → helpers/helper.rb} +2 -2
  26. data/lib/antwort/helpers/logic_helper.rb +81 -0
  27. data/lib/antwort/helpers/markup_helper.rb +37 -0
  28. data/lib/antwort/{builder/helpers/sanitizers.rb → helpers/sanitizers_helper.rb} +2 -4
  29. data/lib/antwort/helpers/server_helper.rb +32 -0
  30. data/lib/antwort/{server.rb → server/server.rb} +26 -23
  31. data/{template/project → lib/antwort/server}/views/404.html.erb +1 -1
  32. data/{template/project → lib/antwort/server}/views/index.html.erb +4 -6
  33. data/{template/project → lib/antwort/server}/views/layout.erb +5 -5
  34. data/{template/project/views/markup/_button.html.erb → lib/antwort/server/views/markup/button.html.erb} +0 -0
  35. data/{template/project/views/markup/_image_tag.html.erb → lib/antwort/server/views/markup/image_tag.html.erb} +0 -0
  36. data/{template/project → lib/antwort/server}/views/server.erb +0 -0
  37. data/lib/antwort/version.rb +1 -1
  38. data/spec/builder/builder_spec.rb +17 -22
  39. data/spec/builder/email_spec.rb +11 -12
  40. data/spec/builder/flattener_spec.rb +20 -21
  41. data/spec/builder/helpers_logic_spec.rb +69 -73
  42. data/spec/builder/partial_spec.rb +42 -51
  43. data/spec/builder/style_spec.rb +25 -34
  44. data/spec/{cli_spec.rb → cli/cli_spec.rb} +8 -9
  45. data/spec/cli/send_spec.rb +80 -0
  46. data/spec/cli/upload_spec.rb +17 -9
  47. data/spec/email/build_spec.rb +13 -0
  48. data/spec/email/collection_spec.rb +56 -0
  49. data/spec/email/data_spec.rb +40 -0
  50. data/spec/email/template_spec.rb +116 -0
  51. data/spec/fixtures/assets/css/demo/include.scss +3 -0
  52. data/spec/fixtures/assets/css/demo/inline.scss +33 -0
  53. data/spec/fixtures/assets/css/no-images/include.scss +1 -0
  54. data/spec/fixtures/assets/css/no-images/inline.scss +2 -0
  55. data/spec/fixtures/assets/css/shared/_base.scss +64 -0
  56. data/spec/fixtures/assets/css/shared/_mixins.scss +25 -0
  57. data/spec/fixtures/assets/css/shared/_reset.scss +59 -0
  58. data/spec/fixtures/assets/css/shared/_vars.scss +12 -0
  59. data/spec/fixtures/assets/css/shared/include.scss +23 -0
  60. data/spec/fixtures/assets/css/shared/inline.scss +9 -0
  61. data/spec/fixtures/build/demo-20160101/demo.html +177 -0
  62. data/spec/fixtures/build/demo-20160101/source/demo.html +118 -0
  63. data/spec/fixtures/build/demo-20160101/source/include.css +58 -0
  64. data/spec/fixtures/build/demo-20160101/source/inline.css +83 -0
  65. data/spec/fixtures/build/demo-20160102/demo.html +177 -0
  66. data/spec/fixtures/build/demo-20160102/source/demo.html +118 -0
  67. data/spec/fixtures/build/demo-20160102/source/include.css +58 -0
  68. data/spec/fixtures/build/demo-20160102/source/inline.css +83 -0
  69. data/{template/project/data/.empty_directory → spec/fixtures/emails/1-demo/_bar.erb} +0 -0
  70. data/spec/fixtures/emails/1-demo/_foo.erb +0 -0
  71. data/spec/fixtures/emails/1-demo/index.html.erb +2 -2
  72. data/spec/fixtures/emails/4-custom-layout/index.html.erb +6 -0
  73. data/spec/fixtures/emails/4-custom-layout/layout.erb +5 -0
  74. data/spec/fixtures/emails/demo/index.html.erb +4 -0
  75. data/spec/fixtures/emails/no-images/index.html.erb +4 -0
  76. data/spec/fixtures/emails/shared/_foo.erb +0 -0
  77. data/spec/fixtures/{views → emails/shared}/layout.erb +0 -0
  78. data/spec/helpers/file_helper_spec.rb +30 -0
  79. data/spec/server/server_spec.rb +57 -0
  80. data/spec/spec_helper.rb +18 -7
  81. data/template/project/Gemfile.tt +1 -7
  82. metadata +92 -42
  83. data/lib/antwort/builder/helpers/logic.rb +0 -82
  84. data/lib/antwort/cli/helpers.rb +0 -44
  85. data/lib/antwort/server/helpers.rb +0 -67
  86. data/lib/antwort/server/markup.rb +0 -39
  87. data/spec/cli/helpers_spec.rb +0 -60
  88. data/spec/fixtures/build/demo-123456/build.html +0 -7
  89. data/spec/fixtures/build/demo-123457/build.html +0 -7
  90. data/spec/fixtures/build/demo-bar-123/build.html +0 -7
  91. data/spec/fixtures/views/404.html.erb +0 -1
  92. data/spec/fixtures/views/index.html.erb +0 -14
  93. data/spec/fixtures/views/server.erb +0 -5
  94. data/spec/server_spec.rb +0 -54
  95. data/template/project/.ruby-version +0 -1
  96. data/template/project/data/config.yml +0 -3
@@ -7,15 +7,15 @@
7
7
  <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- enable media queries for windows phone 8 -->
8
8
  <meta name="format-detection" content="telephone=no"> <!-- disable auto telephone linking in iOS -->
9
9
  <title><%= @title || "Email Title" %></title>
10
- <link rel="stylesheet" type="text/css" href="/assets/<%= @template %>/inline.css">
11
- <link rel="stylesheet" type="text/css" href="/assets/<%= @template %>/include.css">
10
+ <link rel="stylesheet" type="text/css" href="/assets/<%= @template.name %>/inline.css">
11
+ <link rel="stylesheet" type="text/css" href="/assets/<%= @template.name %>/include.css">
12
12
  </head>
13
- <body bgcolor="<%= @config.styles[:background_color] %>" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
13
+ <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
14
14
 
15
15
  <!-- 100% wrapper (grey background) -->
16
- <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" bgcolor="<%= @config.styles[:background_color] %>">
16
+ <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
17
17
  <tr>
18
- <td align="center" valign="top" bgcolor="<%= @config.styles[:background_color] %>" style="background-color: <%= @config.styles[:background_color] %>;">
18
+ <td align="center" valign="top">
19
19
 
20
20
  <br>
21
21
 
@@ -1,3 +1,3 @@
1
1
  module Antwort
2
- VERSION = '0.0.12'
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -1,30 +1,25 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Antwort::Builder do
4
- before :each do
5
- @builder = Antwort::Builder.new
6
- end
4
+ let(:build) { Antwort::Builder.new }
7
5
 
8
- describe "Initialize" do
9
- it "has a template_name"
10
- it "has a build_id"
11
- it "has a markup_dir"
12
- it "has a source_dir"
13
- it "has a scss_dir"
14
- it "has an asset_server"
6
+ describe 'Initialize' do
7
+ it 'has a template_name'
8
+ it 'has a build_id'
9
+ it 'has a markup_dir'
10
+ it 'has a source_dir'
11
+ it 'has a scss_dir'
12
+ it 'has an asset_server'
15
13
  end
16
14
 
17
- describe "Compiles" do
18
- it "SCSS"
19
- it "inline.scss"
20
- it "include.scss"
15
+ describe 'Compiles' do
16
+ it 'SCSS'
17
+ it 'inline.scss'
18
+ it 'include.scss'
21
19
  end
22
20
 
23
- describe "Helpers" do
24
- it "creates files"
25
- it "creates IDs from Timestamps"
26
- it "changes relative assets URLs to use asset server"
27
- it "preserves `&nbsp;`s"
21
+ describe 'Helpers' do
22
+ it 'changes relative assets URLs to use asset server'
23
+ it 'preserves `&nbsp;`s'
28
24
  end
29
-
30
- end
25
+ end
@@ -1,21 +1,20 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Antwort::EmailBuilder do
4
4
  before :each do
5
5
  @builder = Antwort::EmailBuilder.new
6
6
  end
7
7
 
8
- describe "Builds" do
9
- it "builds HTML"
10
- it "inlines CSS"
8
+ describe 'Builds' do
9
+ it 'builds HTML'
10
+ it 'inlines CSS'
11
11
  end
12
12
 
13
- describe "Helpers" do
14
- it "can inline CSS"
15
- it "cleans up markup"
16
- it "removes livereload"
17
- it "adds in the included CSS"
18
- it "removes excessive newlines"
13
+ describe 'Helpers' do
14
+ it 'can inline CSS'
15
+ it 'cleans up markup'
16
+ it 'removes livereload'
17
+ it 'adds in the included CSS'
18
+ it 'removes excessive newlines'
19
19
  end
20
-
21
- end
20
+ end
@@ -1,64 +1,63 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Antwort::Flattener do
4
-
5
- describe "initialize" do
6
- it "saves source to a attr_reader" do
4
+ describe 'initialize' do
5
+ it 'saves source to a attr_reader' do
7
6
  s = Antwort::Flattener.new('<td>')
8
7
  expect(s.source).to eq('<td>')
9
8
  end
10
9
 
11
- describe "saves matches to an array" do
12
- it "matches single style per source" do
10
+ describe 'saves matches to an array' do
11
+ it 'matches single style per source' do
13
12
  s = Antwort::Flattener.new('<div style="color:black">')
14
13
  expect(s.styles).to eq(['color:black'])
15
14
  end
16
- it "matches multiple styles per source" do
15
+ it 'matches multiple styles per source' do
17
16
  s = Antwort::Flattener.new('<td style="background-color:#cccccc"><div style="color: red">')
18
17
  expect(s.styles).to eq(['background-color:#cccccc', 'color: red'])
19
18
  end
20
19
  end
21
20
  end
22
21
 
23
- describe "flattens css styles" do
24
- it "a single match" do
22
+ describe 'flattens css styles' do
23
+ it 'a single match' do
25
24
  s = Antwort::Flattener.new('<div style="color:black;color:red;background:white;">').flatten
26
25
  expect(s.flattened).to eq('<div style="color:red;background:white">')
27
26
  end
28
27
 
29
- describe "multiple styles" do
30
- let (:style) { Antwort::Flattener.new('<td style="color:black;color:red;"><div style="background:white;">').flatten }
28
+ describe 'multiple styles' do
29
+ let(:style) { Antwort::Flattener.new('<td style="color:black;color:red;"><div style="background:white;">').flatten }
31
30
 
32
- it "stores original source as a string" do
31
+ it 'stores original source as a string' do
33
32
  expect(style.source).to eq('<td style="color:black;color:red;"><div style="background:white;">')
34
33
  end
35
34
 
36
- it "stores flattened source as a string" do
35
+ it 'stores flattened source as a string' do
37
36
  expect(style.flattened).to eq('<td style="color:red"><div style="background:white">')
38
37
  end
39
38
  end
40
39
 
41
- describe "method flattened?" do
42
- it "returns true if changes where made" do
40
+ describe 'method flattened?' do
41
+ it 'returns true if changes where made' do
43
42
  s = Antwort::Flattener.new('<td style="color: red; color: black;">').flatten
44
43
  expect(s.flattened?).to eq(true)
45
44
  end
46
- it "returns false if chnages were not made" do
45
+ it 'returns false if chnages were not made' do
47
46
  s = Antwort::Flattener.new('<td style"color:red">').flatten
48
47
  expect(s.flattened?).to eq(false)
49
48
  end
50
49
  end
51
50
  end
52
51
 
53
- describe "code cleanup" do
54
- let (:style) { Antwort::Flattener.new('<td style="color: black;">').flatten }
52
+ describe 'code cleanup' do
53
+ let(:style) { Antwort::Flattener.new('<td style="color: black;">').flatten }
55
54
 
56
- it "removes trailing semicolon;" do
55
+ it 'removes trailing semicolon;' do
57
56
  expect(style.flattened).to eq('<td style="color:black">')
58
57
  expect(style.flattened).not_to eq('<td style="color:black;">')
59
58
  end
60
- it "remove extra white space" do
59
+ it 'remove extra white space' do
61
60
  expect(style.flattened).not_to eq('<td style="color: black">')
62
61
  end
63
62
  end
64
- end
63
+ end
@@ -4,63 +4,62 @@ class Dummy
4
4
  end
5
5
 
6
6
  describe Antwort::LogicHelpers do
7
-
8
7
  before :each do
9
8
  @helper = Dummy.new
10
9
  @helper.extend(Antwort::LogicHelpers)
11
10
  end
12
11
 
13
- describe "non breaking spaces" do
14
- it "preserves by adjusting markup" do
12
+ describe 'non breaking spaces' do
13
+ it 'preserves by adjusting markup' do
15
14
  expect(@helper.preserve_nbsps('foo&nbsp;bar')).to eq('foo%nbspace%bar')
16
15
  end
17
16
 
18
- it "can restore to proper markup" do
17
+ it 'can restore to proper markup' do
19
18
  expect(@helper.restore_nbsps('foo%nbspace%bar')).to eq('foo&nbsp;bar')
20
19
  end
21
20
  end
22
21
 
23
- describe "statements" do
24
- it "preserves erb markup" do
22
+ describe 'statements' do
23
+ it 'preserves erb markup' do
25
24
  expect(@helper.preserve_logic('<% user.merge!({clear: true}) %>')).to eq('{% user.merge!({clear: true}) %}')
26
25
  end
27
26
  end
28
27
 
29
28
  #-- Comments --
30
29
 
31
- describe "comments" do
32
- it "preserves erb comments" do
30
+ describe 'comments' do
31
+ it 'preserves erb comments' do
33
32
  h = {
34
- "<%# foo %>" => "{# foo #}",
35
- "<% # foo %>" => "{# foo #}",
36
- "<% #foo %>" => "{# foo #}",
37
- "<%#= foo %>" => "{#= foo #}",
38
- "<%# foo bar == cat %>" => "{# foo bar == cat #}"
33
+ '<%# foo %>' => '{# foo #}',
34
+ '<% # foo %>' => '{# foo #}',
35
+ '<% #foo %>' => '{# foo #}',
36
+ '<%#= foo %>' => '{#= foo #}',
37
+ '<%# foo bar == cat %>' => '{# foo bar == cat #}'
39
38
  }
40
39
  h.each do |key, value|
41
40
  expect(@helper.preserve_logic(key)).to eq(value)
42
41
  end
43
42
  end
44
43
 
45
- it "preserves comments despite leading/trailing spaces" do
44
+ it 'preserves comments despite leading/trailing spaces' do
46
45
  expect(@helper.preserve_logic('<% # foo %>')).to eq('{# foo #}')
47
46
  end
48
47
  end
49
48
 
50
49
  #-- Variables --
51
50
 
52
- describe "variable outputs" do
53
- it "preserves interpolated strings" do
51
+ describe 'variable outputs' do
52
+ it 'preserves interpolated strings' do
54
53
  expect(@helper.preserve_logic('<%= "color: #{foo};" %>')).to eq('{{ "color: #{foo};" }}')
55
54
  end
56
55
 
57
- context "hashes" do
58
- it "preserves nested" do
56
+ context 'hashes' do
57
+ it 'preserves nested' do
59
58
  expect(@helper.preserve_logic('<%= foo[:bar] %>')).to eq('{{ foo.bar }}')
60
59
  expect(@helper.preserve_logic('<%= foo[:bar][:cat] %>')).to eq('{{ foo.bar.cat }}')
61
60
  end
62
61
 
63
- it "preseves string keys" do
62
+ it 'preseves string keys' do
64
63
  expect(@helper.preserve_logic("<%= foo['bar'] %>")).to eq('{{ foo.bar }}')
65
64
  expect(@helper.preserve_logic("<%= foo['bar']['cat'] %>")).to eq('{{ foo.bar.cat }}')
66
65
  expect(@helper.preserve_logic('<%= foo["bar"] %>')).to eq('{{ foo.bar }}')
@@ -71,56 +70,55 @@ describe Antwort::LogicHelpers do
71
70
 
72
71
  #-- Assignments --
73
72
 
74
- describe "preserves assignments" do
75
-
76
- describe "incl. variables" do
77
- it "well-formatted code" do
78
- expect(@helper.preserve_logic("<% foo = bar %>")).to eq("{% set foo = bar %}")
73
+ describe 'preserves assignments' do
74
+ describe 'incl. variables' do
75
+ it 'well-formatted code' do
76
+ expect(@helper.preserve_logic('<% foo = bar %>')).to eq('{% set foo = bar %}')
79
77
  end
80
78
 
81
- it "not well-formatted code" do
82
- expect(@helper.preserve_logic("<% foo=bar %>")).to eq("{% set foo = bar %}")
83
- expect(@helper.preserve_logic("<% foo =bar %>")).to eq("{% set foo = bar %}")
84
- expect(@helper.preserve_logic("<% foo=bar %>")).to eq("{% set foo = bar %}")
79
+ it 'not well-formatted code' do
80
+ expect(@helper.preserve_logic('<% foo=bar %>')).to eq('{% set foo = bar %}')
81
+ expect(@helper.preserve_logic('<% foo =bar %>')).to eq('{% set foo = bar %}')
82
+ expect(@helper.preserve_logic('<% foo=bar %>')).to eq('{% set foo = bar %}')
85
83
  end
86
84
  end
87
85
 
88
- it "incl. strings" do
86
+ it 'incl. strings' do
89
87
  expect(@helper.preserve_logic('<% foo = "bar" %>')).to eq('{% set foo = "bar" %}')
90
88
  expect(@helper.preserve_logic("<% foo = 'bar' %>")).to eq("{% set foo = 'bar' %}")
91
89
  end
92
90
 
93
- it "incl. integers" do
91
+ it 'incl. integers' do
94
92
  expect(@helper.preserve_logic('<% foo = 1 %>')).to eq('{% set foo = 1 %}')
95
93
  expect(@helper.preserve_logic('<% foo=1 %>')).to eq('{% set foo = 1 %}')
96
94
  end
97
95
 
98
- it "incl. arrays" do
96
+ it 'incl. arrays' do
99
97
  h = {
100
- "<% foo = [1] %>" => "{% set foo = [1] %}",
101
- "<% foo = [ 1 ] %>" => "{% set foo = [ 1 ] %}",
102
- "<% foo = [1,2] %>" => "{% set foo = [1,2] %}",
103
- "<% foo = [1, 2, 3] %>" => "{% set foo = [1, 2, 3] %}"
98
+ '<% foo = [1] %>' => '{% set foo = [1] %}',
99
+ '<% foo = [ 1 ] %>' => '{% set foo = [ 1 ] %}',
100
+ '<% foo = [1,2] %>' => '{% set foo = [1,2] %}',
101
+ '<% foo = [1, 2, 3] %>' => '{% set foo = [1, 2, 3] %}'
104
102
  }
105
103
  h.each do |key, value|
106
104
  expect(@helper.preserve_logic(key)).to eq(value)
107
105
  end
108
106
  end
109
107
 
110
- it "incl. objects/hashes" do
108
+ it 'incl. objects/hashes' do
111
109
  expect(@helper.preserve_logic('<% foo = { key: val } %>')).to eq('{% set foo = { key: val } %}')
112
110
  end
113
111
 
114
- it "respects memoized assignemnts" do
112
+ it 'respects memoized assignemnts' do
115
113
  expect(@helper.preserve_logic('<% foo ||= "bar" %>')).to eq('{% set foo = foo || "bar" %}')
116
114
  end
117
115
  end
118
116
 
119
117
  #-- Conditionals --
120
118
 
121
- describe "conditionals" do
122
- describe "if" do
123
- it "/ end" do
119
+ describe 'conditionals' do
120
+ describe 'if' do
121
+ it '/ end' do
124
122
  h = {
125
123
  '<% if foo %>do something<% end %>' => '{% if foo %}do something{% end %}',
126
124
  '<%if foo%>do something<%end%>' => '{% if foo %}do something{% end %}',
@@ -128,29 +126,29 @@ describe Antwort::LogicHelpers do
128
126
  '<% if foo = \'bar\' %>do something<% end %>' => '{% if foo = \'bar\' %}do something{% end %}',
129
127
  '<% if foo = "bar" %>do something<% end %>' => '{% if foo = "bar" %}do something{% end %}',
130
128
  '<% if i < @config.products.length - 1 %>' => '{% if i < @config.products.length - 1 %}',
131
- '<% if i<@config.products.length-1 %>' => '{% if i<@config.products.length-1 %}'
129
+ '<% if i<@config.products.length-1 %>' => '{% if i<@config.products.length-1 %}'
132
130
  }
133
131
  h.each do |key, value|
134
132
  expect(@helper.preserve_logic(key)).to eq(value)
135
133
  end
136
134
  end
137
135
 
138
- it "/ else / end" do
136
+ it '/ else / end' do
139
137
  expect(@helper.preserve_logic('<% if foo %>bar<% else %>cat<% end %>')).to eq('{% if foo %}bar{% else %}cat{% end %}')
140
138
  end
141
139
 
142
- it "/ elsif / else / end" do
140
+ it '/ elsif / else / end' do
143
141
  expect(@helper.preserve_logic('<% if foo = bar %>bar<% elsif foo = cat %>cat<% else %>dog<% end %>')).to eq('{% if foo = bar %}bar{% elseif foo = cat %}cat{% else %}dog{% end %}')
144
142
  end
145
143
  end
146
144
 
147
- describe "unless" do
148
- it "/ end" do
145
+ describe 'unless' do
146
+ it '/ end' do
149
147
  expect(@helper.preserve_logic('<% unless foo %>')).to eq('{% if !( foo ) %}')
150
148
  expect(@helper.preserve_logic('<% unless foo == bar - 1 %>')).to eq('{% if !( foo == bar - 1 ) %}')
151
149
  end
152
150
 
153
- it "/ else / end" do
151
+ it '/ else / end' do
154
152
  expect(@helper.preserve_logic('<% unless foo == bar %>this<% else %>that<% end %>')).to eq('{% if !( foo == bar ) %}this{% else %}that{% end %}')
155
153
  end
156
154
  end
@@ -158,23 +156,23 @@ describe Antwort::LogicHelpers do
158
156
 
159
157
  #-- Loops --
160
158
 
161
- describe "loops" do
162
- it "preserves each loops as for loops" do
159
+ describe 'loops' do
160
+ it 'preserves each loops as for loops' do
163
161
  h = {
164
- "<% cats.each do |cat| %>" => "{% for cat in cats %}",
165
- "<% cats.each do | cat | %>" => "{% for cat in cats %}",
166
- "<% end %>" => "{% end %}"
162
+ '<% cats.each do |cat| %>' => '{% for cat in cats %}',
163
+ '<% cats.each do | cat | %>' => '{% for cat in cats %}',
164
+ '<% end %>' => '{% end %}'
167
165
  }
168
166
  h.each do |key, value|
169
167
  expect(@helper.preserve_logic(key)).to eq(value)
170
168
  end
171
169
  end
172
170
 
173
- it "preserves each_with_index" do
171
+ it 'preserves each_with_index' do
174
172
  h = {
175
- "<% cats.each_with_index do | cat , i | %>" => "{% for cat in cats with: {@index: i} %}",
176
- "<% cats.each_with_index do |cat, i| %>" => "{% for cat in cats with: {@index: i} %}",
177
- "<% cats.each_with_index do |cat,i| %>" => "{% for cat in cats with: {@index: i} %}"
173
+ '<% cats.each_with_index do | cat , i | %>' => '{% for cat in cats with: {@index: i} %}',
174
+ '<% cats.each_with_index do |cat, i| %>' => '{% for cat in cats with: {@index: i} %}',
175
+ '<% cats.each_with_index do |cat,i| %>' => '{% for cat in cats with: {@index: i} %}'
178
176
  }
179
177
  h.each do |key, value|
180
178
  expect(@helper.preserve_logic(key)).to eq(value)
@@ -184,13 +182,13 @@ describe Antwort::LogicHelpers do
184
182
 
185
183
  #-- Helpers --
186
184
 
187
- describe "Helpers use statements syntax, not output" do
188
- it "includes button" do
185
+ describe 'Helpers use statements syntax, not output' do
186
+ it 'includes button' do
189
187
  expect(@helper.preserve_logic("<%= button 'foo', '#' %>")).to eq("{% button 'foo', '#' %}")
190
188
  expect(@helper.preserve_logic("<%= button 'foo', '#', color: 'blue' %>")).to eq("{% button 'foo', '#', color: 'blue' %}")
191
189
  end
192
190
 
193
- it "includes image_tag" do
191
+ it 'includes image_tag' do
194
192
  expect(@helper.preserve_logic("<%= image_tag 'photo.jpg', width: 100, alt: 'caption' %>")).to eq("{% image_tag 'photo.jpg', width: 100, alt: 'caption' %}")
195
193
  expect(@helper.preserve_logic('<%= image_tag "#{user}-photo.jpg", width: 100, alt: "caption" %>')).to eq('{% image_tag "#{user}-photo.jpg", width: 100, alt: "caption" %}')
196
194
  end
@@ -198,47 +196,45 @@ describe Antwort::LogicHelpers do
198
196
 
199
197
  #-- Partials --
200
198
 
201
- describe "partials are converted to friendlier include syntax" do
202
- it "with locals" do
199
+ describe 'partials are converted to friendlier include syntax' do
200
+ it 'with locals' do
203
201
  expect(@helper.preserve_logic("{{ partial :'foo', locals: bar }}")).to eq("{% include 'foo' with: bar %}")
204
202
  expect(@helper.preserve_logic("{{ partial :'foo', locals:bar }}")).to eq("{% include 'foo' with:bar %}")
205
203
  expect(@helper.preserve_logic("{{ partial :'foo', locals: {cat: cat} }}")).to eq("{% include 'foo' with: {cat: cat} %}")
206
-
207
204
  end
208
205
 
209
- it "including multiline" do
210
- markup = %q(
206
+ it 'including multiline' do
207
+ markup = <<-END
211
208
  <%= partial :'user', locals: {
212
209
  name: 'foo',
213
210
  size: bar
214
211
  } %>
215
- )
216
- result = %q(
212
+ END
213
+ result = <<-END
217
214
  {% include 'user' with: {
218
215
  name: 'foo',
219
216
  size: bar
220
217
  } %}
221
- )
218
+ END
222
219
 
223
220
  expect(@helper.preserve_logic(markup)).to eq(result)
224
221
  end
225
222
 
226
- it "without locals" do
223
+ it 'without locals' do
227
224
  expect(@helper.preserve_logic("{{ partial :'foo' }}")).to eq("{% include 'foo' %}")
228
- expect(@helper.preserve_logic("{{ partial :foo }}")).to eq("{% include foo %}")
225
+ expect(@helper.preserve_logic('{{ partial :foo }}')).to eq('{% include foo %}')
229
226
  end
230
227
  end
231
228
 
232
- describe "multiple statements on one line" do
233
- it "does not match too early" do
229
+ describe 'multiple statements on one line' do
230
+ it 'does not match too early' do
234
231
  h = {
235
- "<% if %>this<% else %>that<%end%>" => "{% if %}this{% else %}that{% end %}",
236
- "<% if i==0 %><%= partial :foo %><% else %><%= partial :bar %><% end %>" => "{% if i==0 %}{% include foo %}{% else %}{% include bar %}{% end %}"
232
+ '<% if %>this<% else %>that<%end%>' => '{% if %}this{% else %}that{% end %}',
233
+ '<% if i==0 %><%= partial :foo %><% else %><%= partial :bar %><% end %>' => '{% if i==0 %}{% include foo %}{% else %}{% include bar %}{% end %}'
237
234
  }
238
235
  h.each do |key, value|
239
236
  expect(@helper.preserve_logic(key)).to eq(value)
240
237
  end
241
238
  end
242
239
  end
243
-
244
240
  end