slim 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,124 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSlimCodeOutput < TestSlim
4
- def test_render_with_call
5
- source = %q{
6
- p
7
- = hello_world
8
- }
9
-
10
- assert_html '<p>Hello World from @env</p>', source #, :debug => true
11
- end
12
-
13
- def test_render_with_conditional_call
14
- source = %q{
15
- p
16
- = hello_world if true
17
- }
18
-
19
- assert_html '<p>Hello World from @env</p>', source
20
- end
21
-
22
- def test_render_with_parameterized_call
23
- source = %q{
24
- p
25
- = hello_world("Hello Ruby!")
26
- }
27
-
28
- assert_html '<p>Hello Ruby!</p>', source
29
- end
30
-
31
- def test_render_with_spaced_parameterized_call
32
- source = %q{
33
- p
34
- = hello_world "Hello Ruby!"
35
- }
36
-
37
- assert_html '<p>Hello Ruby!</p>', source
38
- end
39
-
40
- def test_render_with_spaced_parameterized_call_2
41
- source = %q{
42
- p
43
- = hello_world "Hello Ruby!", :dummy => "value"
44
- }
45
-
46
- assert_html '<p>Hello Ruby!dummy value</p>', source
47
- end
48
-
49
- def test_render_with_call_and_inline_text
50
- source = %q{
51
- h1 This is my title
52
- p
53
- = hello_world
54
- }
55
-
56
- assert_html '<h1>This is my title</h1><p>Hello World from @env</p>', source
57
- end
58
-
59
- def test_render_with_attribute_starts_with_keyword
60
- source = %q{
61
- p = hello_world in_keyword
62
- }
63
-
64
- assert_html '<p>starts with keyword</p>', source
65
- end
66
-
67
- def test_hash_call
68
- source = %q{
69
- p = hash[:a]
70
- }
71
-
72
- assert_html '<p>The letter a</p>', source
73
- end
74
-
75
- def test_tag_output_without_space
76
- source = %q{
77
- p= hello_world
78
- p=hello_world
79
- }
80
-
81
- assert_html '<p>Hello World from @env</p><p>Hello World from @env</p>', source
82
- end
83
-
84
- def test_class_output_without_space
85
- source = %q{
86
- .test=hello_world
87
- #test==hello_world
88
- }
89
-
90
- assert_html '<div class="test">Hello World from @env</div><div id="test">Hello World from @env</div>', source
91
- end
92
-
93
- def test_attribute_output_without_space
94
- source = %q{
95
- p id="test"=hello_world
96
- p(id="test")==hello_world
97
- }
98
-
99
- assert_html '<p id="test">Hello World from @env</p><p id="test">Hello World from @env</p>', source
100
- end
101
-
102
- def test_render_with_backslash_end
103
- source = %q{
104
- p = \
105
- "Hello" + \
106
- " Ruby!"
107
- - variable = 1 + \
108
- 2 + \
109
- 3
110
- = variable + \
111
- 1
112
- }
113
-
114
- assert_html '<p>Hello Ruby!</p>7', source
115
- end
116
-
117
- def test_render_with_no_trailing_character
118
- source = %q{
119
- p
120
- = hello_world}
121
-
122
- assert_html '<p>Hello World from @env</p>', source
123
- end
124
- end
@@ -1,95 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSlimCodeStructure < TestSlim
4
- def test_render_with_conditional
5
- source = %q{
6
- div
7
- - if show_first?
8
- p The first paragraph
9
- - else
10
- p The second paragraph
11
- }
12
-
13
- assert_html '<div><p>The second paragraph</p></div>', source
14
- end
15
-
16
- def test_render_with_consecutive_conditionals
17
- source = %q{
18
- div
19
- - if show_first? true
20
- p The first paragraph
21
- - if show_first? true
22
- p The second paragraph
23
- }
24
-
25
- assert_html '<div><p>The first paragraph</p><p>The second paragraph</p></div>', source
26
- end
27
-
28
- def test_render_with_parameterized_conditional
29
- source = %q{
30
- div
31
- - if show_first? false
32
- p The first paragraph
33
- - else
34
- p The second paragraph
35
- }
36
-
37
- assert_html '<div><p>The second paragraph</p></div>', source
38
- end
39
-
40
- def test_render_with_conditional_and_following_nonconditonal
41
- source = %q{
42
- div
43
- - if true
44
- p The first paragraph
45
- - var = 42
46
- = var
47
- }
48
-
49
- assert_html '<div><p>The first paragraph</p>42</div>', source
50
- end
51
-
52
- def test_render_with_inline_condition
53
- source = %q{
54
- p = hello_world if true
55
- }
56
-
57
- assert_html '<p>Hello World from @env</p>', source
58
- end
59
-
60
- def test_render_with_case
61
- source = %q{
62
- p
63
- - case 42
64
- - when 41
65
- | 1
66
- - when 42
67
- | 42
68
- | is the answer
69
- }
70
-
71
- assert_html '<p>42 is the answer</p>', source
72
- end
73
-
74
- def test_render_with_comments
75
- source = %q{
76
- p Hello
77
- / This is a comment
78
- Another comment
79
- p World
80
- }
81
-
82
- assert_html '<p>Hello</p><p>World</p>', source
83
- end
84
-
85
- def test_render_with_yield
86
- source = %q{
87
- div
88
- == yield :menu
89
- }
90
-
91
- assert_html '<div>This is the menu</div>', source do
92
- 'This is the menu'
93
- end
94
- end
95
- end
@@ -1,65 +0,0 @@
1
- require 'helper'
2
- require 'erb'
3
-
4
- class TestSlimEmbeddedEngines < TestSlim
5
- def test_render_with_embedded_template
6
- source = %q{
7
- p
8
- - text = 'before erb block'
9
- erb:
10
- <b>Hello from <%= text.upcase %>!</b>
11
- Second Line!
12
- <% if true %><%= true %><% end %>
13
- }
14
-
15
- assert_html "<p><b>Hello from BEFORE ERB BLOCK!</b>\nSecond Line!\ntrue\n</p>", source
16
- end
17
-
18
- def test_render_with_interpolated_embedded_template
19
- source = %q{
20
- markdown:
21
- #Header
22
- Hello from #{"Markdown!"}
23
- "Second Line!"
24
- }
25
- assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!\n\"Second Line!\"</p>\n", source
26
- end
27
-
28
- def test_render_with_javascript
29
- # Keep the trailing space behind "javascript: "!
30
- source = %q{
31
- javascript:
32
- $(function() {});
33
- }
34
- assert_html '<script type="text/javascript">$(function() {});</script>', source
35
- end
36
-
37
- def test_render_with_ruby
38
- source = %q{
39
- ruby:
40
- variable = 1 +
41
- 2
42
- = variable
43
- }
44
- assert_html '3', source
45
- end
46
-
47
- def test_render_with_liquid
48
- source = %q{
49
- p
50
- - text = 'before liquid block'
51
- liquid:
52
- <span>{{text}}</span>
53
- }
54
- assert_html "<p><span>before liquid block</span>\n</p>", source
55
- end
56
-
57
- def test_render_with_scss
58
- source = %q{
59
- scss:
60
- $color: #f00;
61
- body { color: $color; }
62
- }
63
- assert_html "<style type=\"text/css\">body {\n color: red; }\n</style>", source
64
- end
65
- end
@@ -1,32 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSlimHtmlEscaping < TestSlim
4
- def test_html_will_not_be_escaped
5
- source = %q{
6
- p <Hello> World, meet "Slim".
7
- }
8
-
9
- assert_html '<p><Hello> World, meet "Slim".</p>', source
10
- end
11
-
12
- def test_html_with_newline_will_not_be_escaped
13
- source = %q{
14
- p
15
- |
16
- <Hello> World,
17
- meet "Slim".
18
- }
19
-
20
- assert_html '<p><Hello> World, meet "Slim".</p>', source
21
- end
22
-
23
- def test_html_with_escaped_interpolation
24
- source = %q{
25
- - x = '"'
26
- - content = '<x>'
27
- p class="#{x}" test #{content}
28
- }
29
-
30
- assert_html '<p class="&quot;">test &lt;x&gt;</p>', source
31
- end
32
- end
@@ -1,251 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSlimHtmlStructure < TestSlim
4
- def test_simple_render
5
- # Keep the trailing space behind "body "!
6
- source = %q{
7
- html
8
- head
9
- title Simple Test Title
10
- body
11
- p Hello World, meet Slim.
12
- }
13
-
14
- assert_html '<html><head><title>Simple Test Title</title></head><body><p>Hello World, meet Slim.</p></body></html>', source
15
- end
16
-
17
- def test_html_namespaces
18
- source = %q{
19
- html:body
20
- html:p html:id="test" Text
21
- }
22
-
23
- assert_html '<html:body><html:p html:id="test">Text</html:p></html:body>', source
24
- end
25
-
26
- def test_doctype
27
- source = %q{
28
- ! doctype 5
29
- html
30
- }
31
-
32
- assert_html '<!DOCTYPE html><html></html>', source
33
- end
34
-
35
- def test_render_with_shortcut_attributes
36
- source = %q{
37
- h1#title This is my title
38
- #notice.hello.world
39
- = hello_world
40
- }
41
-
42
- assert_html '<h1 id="title">This is my title</h1><div class="hello world" id="notice">Hello World from @env</div>', source
43
- end
44
-
45
- def test_render_with_text_block
46
- source = %q{
47
- p
48
- `
49
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
50
- }
51
-
52
- assert_html '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>', source
53
- end
54
-
55
- def test_render_with_text_block_with_subsequent_markup
56
- source = %q{
57
- p
58
- `
59
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
60
- p Some more markup
61
- }
62
-
63
- assert_html '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p><p>Some more markup</p>', source
64
- end
65
-
66
- def test_nested_text
67
- source = %q{
68
- p
69
- |
70
- This is line one.
71
- This is line two.
72
- This is line three.
73
- This is line four.
74
- p This is a new paragraph.
75
- }
76
-
77
- assert_html '<p>This is line one. This is line two. This is line three. This is line four.</p><p>This is a new paragraph.</p>', source
78
- end
79
-
80
- def test_nested_text_with_nested_html_one_same_line
81
- source = %q{
82
- p
83
- | This is line one.
84
- This is line two.
85
- span.bold This is a bold line in the paragraph.
86
- | This is more content.
87
- }
88
-
89
- assert_html '<p>This is line one. This is line two.<span class="bold">This is a bold line in the paragraph.</span> This is more content.</p>', source
90
- end
91
-
92
- def test_nested_text_with_nested_html_one_same_line2
93
- source = %q{
94
- p
95
- |This is line one.
96
- This is line two.
97
- span.bold This is a bold line in the paragraph.
98
- | This is more content.
99
- }
100
-
101
- assert_html '<p>This is line one. This is line two.<span class="bold">This is a bold line in the paragraph.</span> This is more content.</p>', source
102
- end
103
-
104
- def test_nested_text_with_nested_html
105
- source = %q{
106
- p
107
- |
108
- This is line one.
109
- This is line two.
110
- This is line three.
111
- This is line four.
112
- span.bold This is a bold line in the paragraph.
113
- | This is more content.
114
- }
115
-
116
- assert_html '<p>This is line one. This is line two. This is line three. This is line four.<span class="bold">This is a bold line in the paragraph.</span> This is more content.</p>', source
117
- end
118
-
119
- def test_simple_paragraph_with_padding
120
- source = %q{
121
- p There will be 3 spaces in front of this line.
122
- }
123
-
124
- assert_html '<p> There will be 3 spaces in front of this line.</p>', source
125
- end
126
-
127
- def test_paragraph_with_nested_text
128
- source = %q{
129
- p This is line one.
130
- This is line two.
131
- }
132
-
133
- assert_html '<p>This is line one. This is line two.</p>', source
134
- end
135
-
136
- def test_paragraph_with_padded_nested_text
137
- source = %q{
138
- p This is line one.
139
- This is line two.
140
- }
141
-
142
- assert_html '<p> This is line one. This is line two.</p>', source
143
- end
144
-
145
- def test_paragraph_with_attributes_and_nested_text
146
- source = %q{
147
- p#test class="paragraph" This is line one.
148
- This is line two.
149
- }
150
-
151
- assert_html '<p class="paragraph" id="test">This is line one.This is line two.</p>', source
152
- end
153
-
154
- def test_output_code_with_leading_spaces
155
- source = %q{
156
- p= hello_world
157
- p = hello_world
158
- p = hello_world
159
- }
160
-
161
- assert_html '<p>Hello World from @env</p><p>Hello World from @env</p><p>Hello World from @env</p>', source
162
- end
163
-
164
- def test_single_quoted_attributes
165
- source = %q{
166
- p class='underscored_class_name' = output_number
167
- }
168
-
169
- assert_html '<p class="underscored_class_name">1337</p>', source
170
- end
171
-
172
- def test_nonstandard_attributes
173
- source = %q{
174
- p id="dashed-id" class="underscored_class_name" = output_number
175
- }
176
-
177
- assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
178
- end
179
-
180
- def test_nonstandard_shortcut_attributes
181
- source = %q{
182
- p#dashed-id.underscored_class_name = output_number
183
- }
184
-
185
- assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
186
- end
187
-
188
- def test_dashed_attributes
189
- source = %q{
190
- p data-info="Illudium Q-36" = output_number
191
- }
192
-
193
- assert_html '<p data-info="Illudium Q-36">1337</p>', source
194
- end
195
-
196
- def test_dashed_attributes_with_shortcuts
197
- source = %q{
198
- p#marvin.martian data-info="Illudium Q-36" = output_number
199
- }
200
-
201
- assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
202
- end
203
-
204
- def test_parens_around_attributes
205
- source = %q{
206
- p(id="marvin" class="martian" data-info="Illudium Q-36") = output_number
207
- }
208
-
209
- assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
210
- end
211
-
212
- def test_square_brackets_around_attributes
213
- source = %q{
214
- p[id="marvin" class="martian" data-info="Illudium Q-36"] = output_number
215
- }
216
-
217
- assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
218
- end
219
-
220
- def test_parens_around_attributes_with_equal_sign_snug_to_right_paren
221
- source = %q{
222
- p(id="marvin" class="martian" data-info="Illudium Q-36")= output_number
223
- }
224
-
225
- assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
226
- end
227
-
228
- def test_closed_tag
229
- source = %q{
230
- closed/
231
- }
232
-
233
- assert_html '<closed />', source, :format => :xhtml
234
- end
235
-
236
- def test_closed_tag_with_attributes
237
- source = %q{
238
- closed id="test" /
239
- }
240
-
241
- assert_html '<closed id="test" />', source, :format => :xhtml
242
- end
243
-
244
- def test_closed_tag_with_attributes_and_parens
245
- source = %q{
246
- closed(id="test")/
247
- }
248
-
249
- assert_html '<closed id="test" />', source, :format => :xhtml
250
- end
251
- end