padrino-helpers 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/padrino-helpers.rb +4 -1
  3. data/lib/padrino-helpers/asset_tag_helpers.rb +17 -14
  4. data/lib/padrino-helpers/breadcrumb_helpers.rb +6 -6
  5. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +119 -163
  6. data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +92 -0
  7. data/lib/padrino-helpers/form_helpers.rb +66 -347
  8. data/lib/padrino-helpers/form_helpers/errors.rb +138 -0
  9. data/lib/padrino-helpers/form_helpers/options.rb +97 -0
  10. data/lib/padrino-helpers/form_helpers/security.rb +70 -0
  11. data/lib/padrino-helpers/output_helpers.rb +1 -1
  12. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
  13. data/lib/padrino-helpers/render_helpers.rb +10 -9
  14. data/lib/padrino-helpers/tag_helpers.rb +2 -1
  15. data/lib/padrino/rendering.rb +378 -0
  16. data/lib/padrino/rendering/extensions/erubis.rb +74 -0
  17. data/lib/padrino/rendering/extensions/haml.rb +29 -0
  18. data/lib/padrino/rendering/extensions/slim.rb +21 -0
  19. data/padrino-helpers.gemspec +2 -1
  20. data/test/fixtures/apps/.components +6 -0
  21. data/test/fixtures/apps/.gitignore +7 -0
  22. data/test/fixtures/apps/render.rb +25 -0
  23. data/test/fixtures/apps/views/article/comment/show.slim +1 -0
  24. data/test/fixtures/apps/views/blog/post.erb +1 -0
  25. data/test/fixtures/apps/views/layouts/specific.erb +1 -0
  26. data/test/fixtures/apps/views/test/post.erb +1 -0
  27. data/test/fixtures/layouts/layout.erb +1 -0
  28. data/test/fixtures/markup_app/app.rb +0 -1
  29. data/test/fixtures/render_app/app.rb +25 -1
  30. data/test/fixtures/render_app/views/_unsafe.html.builder +2 -0
  31. data/test/fixtures/render_app/views/_unsafe_object.html.builder +2 -0
  32. data/test/fixtures/render_app/views/ruby_block_capture_erb.erb +1 -0
  33. data/test/fixtures/render_app/views/ruby_block_capture_haml.haml +1 -0
  34. data/test/fixtures/render_app/views/ruby_block_capture_slim.slim +1 -0
  35. data/test/helper.rb +65 -1
  36. data/test/test_asset_tag_helpers.rb +83 -79
  37. data/test/test_breadcrumb_helpers.rb +20 -20
  38. data/test/test_form_builder.rb +196 -196
  39. data/test/test_form_helpers.rb +163 -163
  40. data/test/test_format_helpers.rb +65 -65
  41. data/test/test_locale.rb +1 -1
  42. data/test/test_number_helpers.rb +10 -11
  43. data/test/test_output_helpers.rb +28 -28
  44. data/test/test_render_helpers.rb +89 -35
  45. data/test/test_rendering.rb +683 -0
  46. data/test/test_rendering_extensions.rb +14 -0
  47. data/test/test_tag_helpers.rb +23 -23
  48. metadata +57 -5
@@ -12,80 +12,80 @@ describe "FormatHelpers" do
12
12
  Time.stubs(:now).returns(Time.utc(1983, 11, 9, 5))
13
13
  end
14
14
 
15
- context 'for #simple_format method' do
16
- should "format simple text into html format" do
15
+ describe 'for #simple_format method' do
16
+ it 'should format simple text into html format' do
17
17
  actual_text = simple_format("Here is some basic text...\n...with a line break.")
18
18
  assert_equal true, actual_text.html_safe?
19
19
  assert_equal "<p>Here is some basic text...\n<br />...with a line break.</p>", actual_text
20
20
  end
21
21
 
22
- should "format more text into html format" do
22
+ it 'should format more text into html format' do
23
23
  actual_text = simple_format("We want to put a paragraph...\n\n...right there.")
24
24
  assert_equal "<p>We want to put a paragraph...</p>\n\n<p>...right there.</p>", actual_text
25
25
  end
26
26
 
27
- should "support defining a class for the paragraphs" do
27
+ it 'should support defining a class for the paragraphs' do
28
28
  actual_text = simple_format("Look me! A class!", :class => 'description')
29
29
  assert_equal "<p class=\"description\">Look me! A class!</p>", actual_text
30
30
  end
31
31
 
32
- should "escape html tags" do
32
+ it 'should escape html tags' do
33
33
  actual_text = simple_format("Will you escape <b>that</b>?")
34
34
  assert_equal "<p>Will you escape &lt;b&gt;that&lt;&#x2F;b&gt;?</p>", actual_text
35
35
  end
36
36
 
37
- should "support already sanitized text" do
37
+ it 'should support already sanitized text' do
38
38
  actual_text = simple_format("Don't try to escape <b>me</b>!".html_safe)
39
39
  assert_equal "<p>Don't try to escape <b>me</b>!</p>", actual_text
40
40
  end
41
41
 
42
- context 'wrapped in a custom tag' do
43
- should "format simple text into html format" do
42
+ describe 'wrapped in a custom tag' do
43
+ it 'should format simple text into html format' do
44
44
  actual_text = simple_format("Here is some basic text...\n...with a line break.", :tag => :div)
45
45
  assert_equal "<div>Here is some basic text...\n<br />...with a line break.</div>", actual_text
46
46
  end
47
47
 
48
- should "format more text into html format" do
48
+ it 'should format more text into html format' do
49
49
  actual_text = simple_format("We want to put a paragraph...\n\n...right there.", :tag => :div)
50
50
  assert_equal "<div>We want to put a paragraph...</div>\n\n<div>...right there.</div>", actual_text
51
51
  end
52
52
 
53
- should "support defining a class for the paragraphs" do
53
+ it 'should support defining a class for the paragraphs' do
54
54
  actual_text = simple_format("Look me! A class!", :class => 'description', :tag => :div)
55
55
  assert_equal "<div class=\"description\">Look me! A class!</div>", actual_text
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
- context 'for #pluralize method' do
61
- should "return singular count for 1 item collections" do
60
+ describe 'for #pluralize method' do
61
+ it 'should return singular count for 1 item collections' do
62
62
  actual_text = pluralize(1, 'person')
63
63
  assert_equal '1 person', actual_text
64
64
  end
65
- should "return plural count for empty collections" do
65
+ it 'should return plural count for empty collections' do
66
66
  actual_text = pluralize(0, 'person')
67
67
  assert_equal '0 people', actual_text
68
68
  end
69
- should "return plural count for many collections" do
69
+ it 'should return plural count for many collections' do
70
70
  actual_text = pluralize(2, 'person')
71
71
  assert_equal '2 people', actual_text
72
72
  end
73
- should "return pluralized word specified as argument" do
73
+ it 'should return pluralized word specified as argument' do
74
74
  actual_text = pluralize(3, 'person', 'users')
75
75
  assert_equal '3 users', actual_text
76
76
  end
77
77
  end
78
78
 
79
- context 'for #word_wrap method' do
80
- should "return proper formatting for 8 max width" do
79
+ describe 'for #word_wrap method' do
80
+ it 'should return proper formatting for 8 max width' do
81
81
  actual_text = word_wrap('Once upon a time', :line_width => 8)
82
82
  assert_equal "Once\nupon a\ntime", actual_text
83
83
  end
84
- should "return proper formatting for 1 max width" do
84
+ it 'should return proper formatting for 1 max width' do
85
85
  actual_text = word_wrap('Once upon a time', :line_width => 1)
86
86
  assert_equal "Once\nupon\na\ntime", actual_text
87
87
  end
88
- should "return proper formatting for default width" do
88
+ it 'should return proper formatting for default width' do
89
89
  actual_text = word_wrap((1..50).to_a.join(" "))
90
90
  assert_equal (1..30).to_a.join(" ") + "\n" + (31..50).to_a.join(" "), actual_text
91
91
  actual_text = word_wrap((1..50).to_a.join(" "), 80)
@@ -93,157 +93,157 @@ describe "FormatHelpers" do
93
93
  end
94
94
  end
95
95
 
96
- context 'for #highlight method' do
97
- should 'highligth with defaults' do
96
+ describe 'for #highlight method' do
97
+ it 'should highligth with defaults' do
98
98
  actual_text = highlight('Lorem ipsum dolor sit amet', 'dolor')
99
99
  assert_equal 'Lorem ipsum <strong class="highlight">dolor</strong> sit amet', actual_text
100
100
  end
101
101
 
102
- should 'highlight with highlighter' do
102
+ it 'should highlight with highlighter' do
103
103
  actual_text = highlight('Lorem ipsum dolor sit amet', 'dolor', :highlighter => '<span class="custom">\1</span>')
104
104
  assert_equal 'Lorem ipsum <span class="custom">dolor</span> sit amet', actual_text
105
105
  end
106
106
  end
107
107
 
108
- context 'for #truncate method' do
109
- should "support default truncation" do
108
+ describe 'for #truncate method' do
109
+ it 'should support default truncation' do
110
110
  actual_text = truncate("Once upon a time in a world far far away")
111
111
  assert_equal "Once upon a time in a world...", actual_text
112
112
  end
113
- should "support specifying length" do
113
+ it 'should support specifying length' do
114
114
  actual_text = truncate("Once upon a time in a world far far away", :length => 14)
115
115
  assert_equal "Once upon a...", actual_text
116
116
  end
117
- should "support specifying omission text" do
117
+ it 'should support specifying omission text' do
118
118
  actual_text = truncate("And they found that many people were sleeping better.", :length => 25, :omission => "(clipped)")
119
119
  assert_equal "And they found t(clipped)", actual_text
120
120
  end
121
121
  end
122
122
 
123
- context 'for #truncate_words method' do
124
- should "support default truncation" do
123
+ describe 'for #truncate_words method' do
124
+ it 'should support default truncation' do
125
125
  actual_text = truncate_words("Long before books were made, people told stories. They told them to one another and to the children as they sat before the fire. Many of these stories were about interesting people, but most of them were about the ways of fairies and giants.")
126
126
  assert_equal "Long before books were made, people told stories. They told them to one another and to the children as they sat before the fire. Many of these stories were about...", actual_text
127
127
  end
128
- should "support specifying length" do
128
+ it 'should support specifying length' do
129
129
  actual_text = truncate_words("Once upon a time in a world far far away", :length => 8)
130
130
  assert_equal "Once upon a time in a world far...", actual_text
131
131
  end
132
- should "support specifying omission text" do
132
+ it 'should support specifying omission text' do
133
133
  actual_text = truncate_words("And they found that many people were sleeping better.", :length => 4, :omission => "(clipped)")
134
134
  assert_equal "And they found that(clipped)", actual_text
135
135
  end
136
136
  end
137
137
 
138
- context 'for #h and #h! method' do
139
- should "escape the simple html" do
138
+ describe 'for #h and #h! method' do
139
+ it 'should escape the simple html' do
140
140
  assert_equal '&lt;h1&gt;hello&lt;&#x2F;h1&gt;', h('<h1>hello</h1>')
141
141
  assert_equal '&lt;h1&gt;hello&lt;&#x2F;h1&gt;', escape_html('<h1>hello</h1>')
142
142
  end
143
- should "escape all brackets, quotes and ampersands" do
143
+ it 'should escape all brackets, quotes and ampersands' do
144
144
  assert_equal '&lt;h1&gt;&lt;&gt;&quot;&amp;demo&amp;&quot;&lt;&gt;&lt;&#x2F;h1&gt;', h('<h1><>"&demo&"<></h1>')
145
145
  end
146
- should "return default text if text is empty" do
146
+ it 'should return default text if text is empty' do
147
147
  assert_equal 'default', h!("", "default")
148
148
  assert_equal '&nbsp;', h!("")
149
149
  end
150
- should "return text escaped if not empty" do
150
+ it 'should return text escaped if not empty' do
151
151
  assert_equal '&lt;h1&gt;hello&lt;&#x2F;h1&gt;', h!('<h1>hello</h1>')
152
152
  end
153
- should "mark escaped text as safe" do
153
+ it 'should mark escaped text as safe' do
154
154
  assert_equal false, '<h1>hello</h1>'.html_safe?
155
155
  assert_equal true, h('<h1>hello</h1>').html_safe?
156
156
  assert_equal true, h!("", "default").html_safe?
157
157
  end
158
158
  end
159
159
 
160
- context 'for #time_ago_in_words method' do
161
- should "less than 5 seconds" do
160
+ describe 'for #time_ago_in_words method' do
161
+ it 'should less than 5 seconds' do
162
162
  assert_equal 'less than 5 seconds', time_ago_in_words(Time.now, true)
163
163
  end
164
- should "less than 10 seconds" do
164
+ it 'should less than 10 seconds' do
165
165
  assert_equal 'less than 10 seconds', time_ago_in_words(Time.now-5, true)
166
166
  end
167
- should "less than 20 seconds" do
167
+ it 'should less than 20 seconds' do
168
168
  assert_equal 'less than 20 seconds', time_ago_in_words(Time.now-10, true)
169
169
  end
170
- should "less than a minute" do
170
+ it 'should less than a minute' do
171
171
  assert_equal 'less than a minute', time_ago_in_words(Time.now-40, true)
172
172
  end
173
- should "2 minutes" do
173
+ it 'should 2 minutes' do
174
174
  assert_equal '2 minutes', time_ago_in_words(Time.now-120, true)
175
175
  end
176
- should "display today" do
176
+ it 'should display today' do
177
177
  assert_equal 'less than a minute', time_ago_in_words(Time.now)
178
178
  end
179
- should "display yesterday" do
179
+ it 'should display yesterday' do
180
180
  assert_equal '1 day', time_ago_in_words(1.day.ago)
181
181
  end
182
- should "display tomorrow" do
182
+ it 'should display tomorrow' do
183
183
  assert_equal '1 day', time_ago_in_words(1.day.from_now)
184
184
  end
185
- should "return future number of days" do
185
+ it 'should return future number of days' do
186
186
  assert_equal '4 days', time_ago_in_words(4.days.from_now)
187
187
  end
188
- should "return past days ago" do
188
+ it 'should return past days ago' do
189
189
  assert_equal '4 days', time_ago_in_words(4.days.ago)
190
190
  end
191
- should "return formatted archived date" do
191
+ it 'should return formatted archived date' do
192
192
  assert_equal '3 months', time_ago_in_words(100.days.ago)
193
193
  end
194
- should "return formatted archived year date" do
194
+ it 'should return formatted archived year date' do
195
195
  assert_equal 'over 1 year', time_ago_in_words(500.days.ago)
196
196
  end
197
- should 'display now as a minute ago' do
197
+ it 'should display now as a minute ago' do
198
198
  assert_equal '1 minute', time_ago_in_words(1.minute.ago)
199
199
  end
200
- should "display a few minutes ago" do
200
+ it 'should display a few minutes ago' do
201
201
  assert_equal '4 minutes', time_ago_in_words(4.minute.ago)
202
202
  end
203
- should "display an hour ago" do
203
+ it 'should display an hour ago' do
204
204
  assert_equal 'about 1 hour', time_ago_in_words(1.hour.ago + 5.minutes.ago.sec)
205
205
  end
206
- should "display a few hours ago" do
206
+ it 'should display a few hours ago' do
207
207
  assert_equal 'about 3 hours', time_ago_in_words(3.hour.ago + 5.minutes.ago.sec)
208
208
  end
209
- should "display a day ago" do
209
+ it 'should display a day ago' do
210
210
  assert_equal '1 day', time_ago_in_words(1.day.ago)
211
211
  end
212
- should "display a few days ago" do
212
+ it 'should display a few days ago' do
213
213
  assert_equal '5 days', time_ago_in_words(5.days.ago - 5.minutes.ago.sec)
214
214
  end
215
- should "display a month ago" do
215
+ it 'should display a month ago' do
216
216
  assert_equal 'about 1 month', time_ago_in_words(32.days.ago + 5.minutes.ago.sec)
217
217
  end
218
- should "display a few months ago" do
218
+ it 'should display a few months ago' do
219
219
  assert_equal '6 months', time_ago_in_words(180.days.ago - 5.minutes.ago.sec)
220
220
  end
221
- should "display a year ago" do
221
+ it 'should display a year ago' do
222
222
  assert_equal 'about 1 year', time_ago_in_words(365.days.ago - 5.minutes.ago.sec)
223
223
  end
224
- should "display a few years ago" do
224
+ it 'should display a few years ago' do
225
225
  assert_equal 'over 7 years', time_ago_in_words(2800.days.ago - 5.minutes.ago.sec)
226
226
  end
227
227
  end
228
228
 
229
- context 'for #js_escape_html method' do
230
- should "escape double quotes" do
229
+ describe 'for #js_escape_html method' do
230
+ it 'should escape double quotes' do
231
231
  assert_equal "\\\"hello\\\"", js_escape_html('"hello"')
232
232
  assert_equal "\\\"hello\\\"", js_escape_html(ActiveSupport::SafeBuffer.new('"hello"'))
233
233
  end
234
- should "escape single quotes" do
234
+ it 'should escape single quotes' do
235
235
  assert_equal "\\'hello\\'", js_escape_html("'hello'")
236
236
  assert_equal "\\'hello\\'", js_escape_html(ActiveSupport::SafeBuffer.new("'hello'"))
237
237
  end
238
- should "escape html tags and breaks" do
238
+ it 'should escape html tags and breaks' do
239
239
  assert_equal "\\n\\n<p>hello<\\/p>\\n", js_escape_html("\n\r<p>hello</p>\r\n")
240
240
  assert_equal "\\n\\n<p>hello<\\/p>\\n", js_escape_html(ActiveSupport::SafeBuffer.new("\n\r<p>hello</p>\r\n"))
241
241
  end
242
- should "escape data-confirm attribute" do
242
+ it 'should escape data-confirm attribute' do
243
243
  assert_equal "<data-confirm=\\\"are you sure\\\">", js_escape_html("<data-confirm=\"are you sure\">")
244
244
  assert_equal "<data-confirm=\\\"are you sure\\\">", js_escape_html(ActiveSupport::SafeBuffer.new("<data-confirm=\"are you sure\">"))
245
245
  end
246
- should "keep html_safe content html_safe" do
246
+ it 'should keep html_safe content html_safe' do
247
247
  assert_equal false, js_escape_html('"hello"').html_safe?
248
248
  assert_equal true, js_escape_html(ActiveSupport::SafeBuffer.new('"hello"')).html_safe?
249
249
  end
data/test/test_locale.rb CHANGED
@@ -4,7 +4,7 @@ describe "Locale Helpers" do
4
4
  Dir[File.expand_path("../../lib/padrino-helpers/locale/*.yml", __FILE__)].each do |file|
5
5
  base_original = YAML.load_file(file)
6
6
  name = File.basename(file, '.yml')
7
- should "should have correct locale for #{name}" do
7
+ it "should should have correct locale for #{name}" do
8
8
  base = base_original[name]['number']['format']
9
9
  assert !base['separator'].nil?
10
10
  assert !base['delimiter'].nil?
@@ -24,9 +24,8 @@ describe "NumberHelpers" do
24
24
  gigabytes(number) * 1024
25
25
  end
26
26
 
27
- context 'for number helpers functionality' do
28
-
29
- should 'display number_to_currency' do
27
+ describe 'for number helpers functionality' do
28
+ it 'should display number_to_currency' do
30
29
  assert_equal "$1,234,567,890.50", number_to_currency(1234567890.50)
31
30
  assert_equal "$1,234,567,890.51", number_to_currency(1234567890.506)
32
31
  assert_equal "$1,234,567,892", number_to_currency(1234567891.50, {:precision => 0})
@@ -39,7 +38,7 @@ describe "NumberHelpers" do
39
38
  assert_nil number_to_currency(nil)
40
39
  end
41
40
 
42
- should 'display number_to_percentage' do
41
+ it 'should display number_to_percentage' do
43
42
  assert_equal "100.000%", number_to_percentage(100)
44
43
  assert_equal "100%", number_to_percentage(100, {:precision => 0})
45
44
  assert_equal "302.06%", number_to_percentage(302.0574, {:precision => 2})
@@ -51,7 +50,7 @@ describe "NumberHelpers" do
51
50
  assert_nil number_to_percentage(nil)
52
51
  end
53
52
 
54
- should 'display number_with_delimiter' do
53
+ it 'should display number_with_delimiter' do
55
54
  assert_equal "12,345,678", number_with_delimiter(12345678)
56
55
  assert_equal "0", number_with_delimiter(0)
57
56
  assert_equal "123", number_with_delimiter(123)
@@ -67,14 +66,14 @@ describe "NumberHelpers" do
67
66
  assert_nil number_with_delimiter(nil)
68
67
  end
69
68
 
70
- should 'display number_with_delimiter with options' do
69
+ it 'should display number_with_delimiter with options' do
71
70
  assert_equal '12 345 678', number_with_delimiter(12345678, :delimiter => ' ')
72
71
  assert_equal '12,345,678-05', number_with_delimiter(12345678.05, :separator => '-')
73
72
  assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.')
74
73
  assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',')
75
74
  end
76
75
 
77
- should 'display number_with_precision' do
76
+ it 'should display number_with_precision' do
78
77
  assert_equal "111.235", number_with_precision(111.2346)
79
78
  assert_equal "31.83", number_with_precision(31.825, :precision => 2)
80
79
  assert_equal "111.23", number_with_precision(111.2346, :precision => 2)
@@ -90,12 +89,12 @@ describe "NumberHelpers" do
90
89
  assert_nil number_with_precision(nil)
91
90
  end
92
91
 
93
- should 'display number_with_precision with custom delimiter and separator' do
92
+ it 'should display number_with_precision with custom delimiter and separator' do
94
93
  assert_equal '31,83', number_with_precision(31.825, :precision => 2, :separator => ',')
95
94
  assert_equal '1.231,83', number_with_precision(1231.825, :precision => 2, :separator => ',', :delimiter => '.')
96
95
  end
97
96
 
98
- should 'display number_to_human_size' do
97
+ it 'should display number_to_human_size' do
99
98
  assert_equal '0 Bytes', number_to_human_size(0)
100
99
  assert_equal '1 Byte', number_to_human_size(1)
101
100
  assert_equal '3 Bytes', number_to_human_size(3.14159265)
@@ -122,7 +121,7 @@ describe "NumberHelpers" do
122
121
  assert_nil number_to_human_size(nil)
123
122
  end
124
123
 
125
- should 'display number_to_human_size with options' do
124
+ it 'should display number_to_human_size with options' do
126
125
  assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2)
127
126
  assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4)
128
127
  assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2)
@@ -134,7 +133,7 @@ describe "NumberHelpers" do
134
133
  assert_equal '40 KB', number_to_human_size(41100, :precision => 0)
135
134
  end
136
135
 
137
- should 'display number_to_human_size with custom delimiter and separator' do
136
+ it 'should display number_to_human_size with custom delimiter and separator' do
138
137
  assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2, :separator => ',')
139
138
  assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4, :separator => ',')
140
139
  assert_equal '1.000,1 TB', number_to_human_size(terabytes(1000.1), :delimiter => '.', :separator => ',')
@@ -6,8 +6,8 @@ describe "OutputHelpers" do
6
6
  MarkupDemo
7
7
  end
8
8
 
9
- context 'for #content_for method' do
10
- should 'work for erb templates' do
9
+ describe 'for #content_for method' do
10
+ it 'should work for erb templates' do
11
11
  visit '/erb/content_for'
12
12
  assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
13
13
  assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
@@ -15,7 +15,7 @@ describe "OutputHelpers" do
15
15
  assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
16
16
  end
17
17
 
18
- should "work for haml templates" do
18
+ it 'should work for haml templates' do
19
19
  visit '/haml/content_for'
20
20
  assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
21
21
  assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
@@ -23,7 +23,7 @@ describe "OutputHelpers" do
23
23
  assert_have_selector '.demo3 p', :content => "Two", :class => "duplication"
24
24
  end
25
25
 
26
- should "work for slim templates" do
26
+ it 'should work for slim templates' do
27
27
  visit '/slim/content_for'
28
28
  assert_have_selector '.demo h1', :content => "This is content yielded from a content_for", :count => 1
29
29
  assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith", :count => 1
@@ -32,85 +32,85 @@ describe "OutputHelpers" do
32
32
  end
33
33
  end # content_for
34
34
 
35
- context "for #content_for? method" do
36
- should 'work for erb templates' do
35
+ describe "for #content_for? method" do
36
+ it 'should work for erb templates' do
37
37
  visit '/erb/content_for'
38
38
  assert_have_selector '.demo_has_content', :content => "true"
39
39
  assert_have_selector '.fake_has_content', :content => "false"
40
40
  end
41
41
 
42
- should "work for haml templates" do
42
+ it 'should work for haml templates' do
43
43
  visit '/haml/content_for'
44
44
  assert_have_selector '.demo_has_content', :content => "true"
45
45
  assert_have_selector '.fake_has_content', :content => "false"
46
46
  end
47
47
 
48
- should "work for slim templates" do
48
+ it 'should work for slim templates' do
49
49
  visit '/slim/content_for'
50
50
  assert_have_selector '.demo_has_content', :content => "true"
51
51
  assert_have_selector '.fake_has_content', :content => "false"
52
52
  end
53
53
  end # content_for?
54
54
 
55
- context 'for #capture_html method' do
56
- should "work for erb templates" do
55
+ describe 'for #capture_html method' do
56
+ it 'should work for erb templates' do
57
57
  visit '/erb/capture_concat'
58
58
  assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
59
59
  assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
60
60
  end
61
61
 
62
- should "work for haml templates" do
62
+ it 'should work for haml templates' do
63
63
  visit '/haml/capture_concat'
64
64
  assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
65
65
  assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
66
66
  end
67
67
 
68
- should "work for slim templates" do
68
+ it 'should work for slim templates' do
69
69
  visit '/slim/capture_concat'
70
70
  assert_have_selector 'p span', :content => "Captured Line 1", :count => 1
71
71
  assert_have_selector 'p span', :content => "Captured Line 2", :count => 1
72
72
  end
73
73
  end
74
74
 
75
- context 'for #concat_content method' do
76
- should "work for erb templates" do
75
+ describe 'for #concat_content method' do
76
+ it 'should work for erb templates' do
77
77
  visit '/erb/capture_concat'
78
78
  assert_have_selector 'p', :content => "Concat Line 3", :count => 1
79
79
  end
80
80
 
81
- should "work for haml templates" do
81
+ it 'should work for haml templates' do
82
82
  visit '/haml/capture_concat'
83
83
  assert_have_selector 'p', :content => "Concat Line 3", :count => 1
84
84
  end
85
85
 
86
- should "work for slim templates" do
86
+ it 'should work for slim templates' do
87
87
  visit '/slim/capture_concat'
88
88
  assert_have_selector 'p', :content => "Concat Line 3", :count => 1
89
89
  end
90
90
  end
91
91
 
92
- context 'for #block_is_template?' do
93
- should "work for erb templates" do
92
+ describe 'for #block_is_template?' do
93
+ it 'should work for erb templates' do
94
94
  visit '/erb/capture_concat'
95
95
  assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template', :count => 1
96
96
  assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
97
97
  end
98
98
 
99
- should "work for haml templates" do
99
+ it 'should work for haml templates' do
100
100
  visit '/haml/capture_concat'
101
101
  assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template', :count => 1
102
102
  assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
103
103
  end
104
104
 
105
- should "work for slim templates" do
105
+ it 'should work for slim templates' do
106
106
  visit '/slim/capture_concat'
107
107
  assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template', :count => 1
108
108
  assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template', :count => 1
109
109
  end
110
110
  end
111
111
 
112
- context 'for #current_engine method' do
113
- should 'detect correctly current engine for erb' do
112
+ describe 'for #current_engine method' do
113
+ it 'should detect correctly current engine for erb' do
114
114
  visit '/erb/current_engine'
115
115
  assert_have_selector 'p.start', :content => "erb"
116
116
  assert_have_selector 'p.haml', :content => "haml"
@@ -119,7 +119,7 @@ describe "OutputHelpers" do
119
119
  assert_have_selector 'p.end', :content => "erb"
120
120
  end
121
121
 
122
- should 'detect correctly current engine for haml' do
122
+ it 'should detect correctly current engine for haml' do
123
123
  visit '/haml/current_engine'
124
124
  assert_have_selector 'p.start', :content => "haml"
125
125
  assert_have_selector 'p.haml', :content => "haml"
@@ -128,7 +128,7 @@ describe "OutputHelpers" do
128
128
  assert_have_selector 'p.end', :content => "haml"
129
129
  end
130
130
 
131
- should 'detect correctly current engine for slim' do
131
+ it 'should detect correctly current engine for slim' do
132
132
  visit '/slim/current_engine'
133
133
  assert_have_selector 'p.start', :content => "slim"
134
134
  assert_have_selector 'p.haml', :content => "haml"
@@ -138,18 +138,18 @@ describe "OutputHelpers" do
138
138
  end
139
139
  end
140
140
 
141
- context 'for #partial method in simple sinatra application' do
142
- should 'properly output in erb' do
141
+ describe 'for #partial method in simple sinatra application' do
142
+ it 'should properly output in erb' do
143
143
  visit '/erb/simple_partial'
144
144
  assert_have_selector 'p.erb', :content => "erb"
145
145
  end
146
146
 
147
- should 'properly output in haml' do
147
+ it 'should properly output in haml' do
148
148
  visit '/haml/simple_partial'
149
149
  assert_have_selector 'p.haml', :content => "haml"
150
150
  end
151
151
 
152
- should 'properly output in slim' do
152
+ it 'should properly output in slim' do
153
153
  visit '/slim/simple_partial'
154
154
  assert_have_selector 'p.slim', :content => "slim"
155
155
  end