tiny 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a25f5692ba1dfbb0a1d206402dc725ef45c0493
4
+ data.tar.gz: c520045fc273ddb2257ce4e6fe6047bd3513da39
5
+ SHA512:
6
+ metadata.gz: 98043c8f9fd4d1cc7a19a06c11f5c617797228a854119636551490192aa7688a63fa374539ffb1cf6c015b1730b3625a0bd5a8173469490186068a02b003b15c
7
+ data.tar.gz: 020ea10b6826e86b562f0d99e1dcd58f998f70a721e5b18f2610911f30e2bdf5cf1a027ae6fa901d01490017f5474d2adf81ff9abad82e7b8705668ecba10133
@@ -1,6 +1,6 @@
1
1
  require 'erubis'
2
2
  require 'tilt'
3
- require 'escape_utils'
3
+ require 'cgi'
4
4
 
5
5
  require 'tiny/version'
6
6
  require 'tiny/erubis'
@@ -43,6 +43,8 @@ module Tiny
43
43
  # # => <textarea disabled></textarea>
44
44
  # html_tag(:textarea, :disabled => false)
45
45
  # # => <textarea></textarea>
46
+ # html_tag(:textarea, :disabled => nil)
47
+ # # => <textarea></textarea>
46
48
  #
47
49
  # @example HTML-escaping
48
50
  #
@@ -350,9 +352,13 @@ module Tiny
350
352
  if value.respond_to?(:html_safe?) && value.html_safe?
351
353
  value.to_s
352
354
  else
353
- EscapeUtils.escape_html value.to_s
355
+ escape_html value.to_s
354
356
  end
355
357
  end
358
+
359
+ def self.escape_html html
360
+ CGI.escapeHTML html.to_s
361
+ end
356
362
  end
357
363
 
358
364
  # Support for HTML markup generation for classes, can be included in
@@ -15,7 +15,7 @@ module Tiny
15
15
  next name if val == true
16
16
 
17
17
  vals = [*val].map do |value|
18
- EscapeUtils.escape_html value.to_s, false
18
+ Helpers.escape_html value
19
19
  end
20
20
 
21
21
  %{#{name}="#{vals.join(' ')}"}
@@ -1,3 +1,3 @@
1
1
  module Tiny
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -2,28 +2,28 @@ require 'spec_helper'
2
2
 
3
3
  describe 'markup helpers' do
4
4
  it "should register tiny erubis templates for '.erubis' files" do
5
- Tilt['erubis'].should == Tiny::Erubis::ErubisTemplate
6
- Tilt['erb'].should == Tiny::Erubis::ErubisTemplate
5
+ expect(Tilt['erubis']).to eq(Tiny::Erubis::ErubisTemplate)
6
+ expect(Tilt['erb']).to eq(Tiny::Erubis::ErubisTemplate)
7
7
  end
8
8
 
9
9
  it 'should default to tiny erubis engine' do
10
10
  engine = Tilt['erb'].new{}.instance_variable_get(:@engine)
11
- engine.should be_a Tiny::Erubis::Eruby
11
+ expect(engine).to be_a Tiny::Erubis::Eruby
12
12
  end
13
13
 
14
14
  it 'should use tiny escaped erubis engine for escaping html' do
15
15
  engine = Tilt['erb'].new(nil, :escape_html => true){}.instance_variable_get(:@engine)
16
- engine.should be_a Tiny::Erubis::EscapedEruby
16
+ expect(engine).to be_a Tiny::Erubis::EscapedEruby
17
17
  end
18
18
 
19
19
  it 'should escape html when passing :escape_html => true option' do
20
20
  template = Tilt['erb'].new(nil, :escape_html => true) { %(<%= "<p>Hello World!</p>" %>) }
21
- template.render.should == "&lt;p&gt;Hello World!&lt;&#47;p&gt;"
21
+ expect(template.render).to eq("&lt;p&gt;Hello World!&lt;/p&gt;")
22
22
  end
23
23
 
24
24
  it 'should not escape htmle when passing :escape_html => false option' do
25
25
  template = Tilt['erb'].new(nil, :escape_html => false) { %(<%= "<p>Hello World!</p>" %>) }
26
- template.render.should == "<p>Hello World!</p>"
26
+ expect(template.render).to eq("<p>Hello World!</p>")
27
27
  end
28
28
 
29
29
  it 'should allow block with explicit output' do
@@ -33,7 +33,7 @@ describe 'markup helpers' do
33
33
  <% end %>
34
34
  ERB
35
35
  end
36
- template.render.should include "[1, 2]"
36
+ expect(template.render).to include "[1, 2]"
37
37
  end
38
38
 
39
39
  it 'should allow block with explicit output' do
@@ -43,6 +43,6 @@ describe 'markup helpers' do
43
43
  <% end %>
44
44
  ERB
45
45
  end
46
- template.render.should include "[1, 2]"
46
+ expect(template.render).to include "[1, 2]"
47
47
  end
48
48
  end
@@ -14,45 +14,45 @@ describe 'markup helpers' do
14
14
  before do
15
15
  @output = tag(:li, :class => 'item', :id => 'hello') { text 'Hello' }
16
16
  end
17
- it { output.should have_css 'li', :count => 1 }
18
- it { output.should have_css 'li', :text => "Hello" }
19
- it { output.should have_css 'li.item' }
20
- it { output.should have_css 'li#hello' }
17
+ it { expect(output).to have_css 'li', :count => 1 }
18
+ it { expect(output).to have_css 'li', :text => "Hello" }
19
+ it { expect(output).to have_css 'li.item' }
20
+ it { expect(output).to have_css 'li#hello' }
21
21
  end
22
22
 
23
23
  it 'should not use blank attribute values' do
24
24
  output = tag(:li, :class => [], :id => nil)
25
- output.should == "<li></li>"
25
+ expect(output).to eq("<li></li>")
26
26
  end
27
27
 
28
28
  it 'should not emit value for an atribute value of true' do
29
29
  output = tag(:li, 'data-something' => true)
30
- output.should == "<li data-something></li>"
30
+ expect(output).to eq("<li data-something></li>")
31
31
  end
32
32
 
33
33
  it 'should not emit value if value is false' do
34
34
  output = tag(:li, 'data-something' => false)
35
- output.should == "<li></li>"
35
+ expect(output).to eq("<li></li>")
36
36
  end
37
37
 
38
38
  it 'should not allow passing text without #text' do
39
39
  output = tag(:li) { 'Hello' }
40
- output.should == '<li></li>'
40
+ expect(output).to eq('<li></li>')
41
41
  end
42
42
 
43
43
  it 'should output multiple classes passing an array' do
44
44
  output = tag(:li, :class => %w(item in-stock))
45
- output.should == '<li class="item in-stock"></li>'
45
+ expect(output).to eq('<li class="item in-stock"></li>')
46
46
  end
47
47
 
48
48
  it 'should allow passing content as string' do
49
- tag(:h1, "Hello").should == "<h1>Hello</h1>"
50
- tag(:h1, "Hello", :class => 'main').should == %{<h1 class="main">Hello</h1>}
49
+ expect(tag(:h1, "Hello")).to eq("<h1>Hello</h1>")
50
+ expect(tag(:h1, "Hello", :class => 'main')).to eq(%{<h1 class="main">Hello</h1>})
51
51
  end
52
52
 
53
53
  it 'should escape attribute html' do
54
- tag(:a, :href => '<script>').should == '<a href="&lt;script&gt;"></a>'
55
- tag(:a, :href => 'art&copy').should == '<a href="art&amp;copy"></a>'
54
+ expect(tag(:a, :href => '<script>')).to eq('<a href="&lt;script&gt;"></a>')
55
+ expect(tag(:a, :href => 'art&copy')).to eq('<a href="art&amp;copy"></a>')
56
56
  end
57
57
  end
58
58
 
@@ -61,9 +61,9 @@ describe 'markup helpers' do
61
61
  before do
62
62
  @output = tag(:div) { tag(:a) { text 'Hello' } }
63
63
  end
64
- it { output.should have_css 'div', :count => 1 }
65
- it { output.should have_css 'a', :count => 1 }
66
- it { output.should have_css 'div > a', :text => 'Hello' }
64
+ it { expect(output).to have_css 'div', :count => 1 }
65
+ it { expect(output).to have_css 'a', :count => 1 }
66
+ it { expect(output).to have_css 'div > a', :text => 'Hello' }
67
67
  end
68
68
 
69
69
  describe 'deeper blocks' do
@@ -75,12 +75,12 @@ describe 'markup helpers' do
75
75
  end
76
76
  end
77
77
  end
78
- it { output.should have_css 'div', :count => 1 }
79
- it { output.should have_css 'a', :count => 1 }
80
- it { output.should have_css 'div > a' }
81
- it { output.should have_css 'div > a', :text => 'Hello' }
82
- it { output.should have_css 'img', :count => 1 }
83
- it { output.should have_css 'div > a > img' }
78
+ it { expect(output).to have_css 'div', :count => 1 }
79
+ it { expect(output).to have_css 'a', :count => 1 }
80
+ it { expect(output).to have_css 'div > a' }
81
+ it { expect(output).to have_css 'div > a', :text => 'Hello' }
82
+ it { expect(output).to have_css 'img', :count => 1 }
83
+ it { expect(output).to have_css 'div > a > img' }
84
84
  end
85
85
  end
86
86
 
@@ -94,9 +94,9 @@ describe 'markup helpers' do
94
94
  end
95
95
  end
96
96
 
97
- it { output.should have_css 'ul', :count => 1 }
98
- it { output.should have_css 'li', :count => 3 }
99
- it { output.should have_css 'ul > li', :count => 3 }
97
+ it { expect(output).to have_css 'ul', :count => 1 }
98
+ it { expect(output).to have_css 'li', :count => 3 }
99
+ it { expect(output).to have_css 'ul > li', :count => 3 }
100
100
  end
101
101
 
102
102
  describe 'concatenation with text' do
@@ -108,12 +108,12 @@ describe 'markup helpers' do
108
108
  end
109
109
  end
110
110
 
111
- it { output.should have_css 'ul', :count => 1 }
112
- it { output.should have_css 'li', :count => 3 }
113
- it { output.should have_css 'ul > li', :count => 3 }
114
- it { output.should have_css 'ul > li', :text => 'One' }
115
- it { output.should have_css 'ul > li', :text => 'Two' }
116
- it { output.should have_css 'ul > li', :text => 'Three' }
111
+ it { expect(output).to have_css 'ul', :count => 1 }
112
+ it { expect(output).to have_css 'li', :count => 3 }
113
+ it { expect(output).to have_css 'ul > li', :count => 3 }
114
+ it { expect(output).to have_css 'ul > li', :text => 'One' }
115
+ it { expect(output).to have_css 'ul > li', :text => 'Two' }
116
+ it { expect(output).to have_css 'ul > li', :text => 'Three' }
117
117
  end
118
118
 
119
119
  describe 'nested' do
@@ -125,19 +125,19 @@ describe 'markup helpers' do
125
125
  end
126
126
  end
127
127
 
128
- it { output.should have_css 'ul', :count => 1 }
129
- it { output.should have_css 'li', :count => 3 }
130
- it { output.should have_css 'ul > li', :count => 3 }
131
- it { output.should have_css 'a', :count => 3 }
132
- it { output.should have_css 'ul > li > a', :text => 'One' }
133
- it { output.should have_css 'ul > li > a', :text => 'Two' }
134
- it { output.should have_css 'ul > li > a', :text => 'Three' }
128
+ it { expect(output).to have_css 'ul', :count => 1 }
129
+ it { expect(output).to have_css 'li', :count => 3 }
130
+ it { expect(output).to have_css 'ul > li', :count => 3 }
131
+ it { expect(output).to have_css 'a', :count => 3 }
132
+ it { expect(output).to have_css 'ul > li > a', :text => 'One' }
133
+ it { expect(output).to have_css 'ul > li > a', :text => 'Two' }
134
+ it { expect(output).to have_css 'ul > li > a', :text => 'Three' }
135
135
  end
136
136
 
137
137
  describe 'outside content block' do
138
138
  it 'should not buffer contiguous tags' do
139
139
  tag(:span)
140
- tag(:a).should == '<a></a>'
140
+ expect(tag(:a)).to eq('<a></a>')
141
141
  end
142
142
  end
143
143
  end
@@ -145,12 +145,12 @@ describe 'markup helpers' do
145
145
  describe 'text' do
146
146
  it 'should escape text' do
147
147
  @output = tag(:li){ text '&<>' }
148
- @output.should =~ /&amp;&lt;&gt;/
148
+ expect(@output).to match(/&amp;&lt;&gt;/)
149
149
  end
150
150
 
151
151
  it 'should allow not scaped text' do
152
152
  @output = tag(:li){ append! '&<>' }
153
- @output.should =~ /&<>/
153
+ expect(@output).to match(/&<>/)
154
154
  end
155
155
  end
156
156
 
@@ -160,7 +160,7 @@ describe 'markup helpers' do
160
160
  tag :li
161
161
  tag :li
162
162
  end
163
- output.should == "<ul>\n <li></li>\n <li></li>\n</ul>"
163
+ expect(output).to eq("<ul>\n <li></li>\n <li></li>\n</ul>")
164
164
  end
165
165
 
166
166
  it 'should buffer with newlines after text' do
@@ -170,7 +170,7 @@ describe 'markup helpers' do
170
170
  append! 'Hi'
171
171
  end
172
172
  end
173
- output.should == "<ul>\n <li>\n Hi\n Hi\n </li>\n</ul>"
173
+ expect(output).to eq("<ul>\n <li>\n Hi\n Hi\n </li>\n</ul>")
174
174
  end
175
175
  end
176
176
  end
@@ -178,44 +178,44 @@ describe 'markup helpers' do
178
178
  describe 'special nodes' do
179
179
  describe 'comments' do
180
180
  it 'should emit comment' do
181
- comment('Hello').should == "<!-- Hello -->"
182
- comment('Hello -- world').should == "<!-- Hello - - world -->"
183
- comment('Hello -- -- world').should == "<!-- Hello - - - - world -->"
181
+ expect(comment('Hello')).to eq("<!-- Hello -->")
182
+ expect(comment('Hello -- world')).to eq("<!-- Hello - - world -->")
183
+ expect(comment('Hello -- -- world')).to eq("<!-- Hello - - - - world -->")
184
184
  end
185
185
 
186
186
  it 'should buffer comments' do
187
- tag(:div) do
187
+ expect(tag(:div) do
188
188
  comment 'foo'
189
189
  comment 'bar'
190
- end.should == "<div>\n <!-- foo -->\n <!-- bar -->\n</div>"
190
+ end).to eq("<div>\n <!-- foo -->\n <!-- bar -->\n</div>")
191
191
  end
192
192
  end
193
193
 
194
194
  describe 'cdata' do
195
195
  it 'should emit cdata' do
196
- cdata('Hello').should == "<![CDATA[Hello]]>"
196
+ expect(cdata('Hello')).to eq("<![CDATA[Hello]]>")
197
197
  end
198
198
 
199
199
  it 'should buffer cdata' do
200
- tag(:div) do
200
+ expect(tag(:div) do
201
201
  cdata('foo')
202
202
  cdata('bar')
203
- end.should == "<div>\n <![CDATA[foo]]>\n <![CDATA[bar]]>\n</div>"
203
+ end).to eq("<div>\n <![CDATA[foo]]>\n <![CDATA[bar]]>\n</div>")
204
204
  end
205
205
 
206
206
  it 'should not "escape" cdata terminator' do
207
- cdata(']]>').should == "<![CDATA[]]]]><![CDATA[>]]>"
207
+ expect(cdata(']]>')).to eq("<![CDATA[]]]]><![CDATA[>]]>")
208
208
  end
209
209
  end
210
210
 
211
211
  describe 'doctype' do
212
212
  it 'should emit html5 doctype' do
213
- doctype.should == '<!DOCTYPE html>'
213
+ expect(doctype).to eq('<!DOCTYPE html>')
214
214
  end
215
215
 
216
216
  it 'should buffer doctype' do
217
217
  output = with_buffer{ doctype and tag(:html) }
218
- output.should == "<!DOCTYPE html>\n<html></html>\n"
218
+ expect(output).to eq("<!DOCTYPE html>\n<html></html>\n")
219
219
 
220
220
  end
221
221
  end
@@ -224,18 +224,18 @@ describe 'markup helpers' do
224
224
  describe 'tag closing' do
225
225
  describe 'void tags' do
226
226
  it 'should define void tags' do
227
- Tiny::HTML.void_tags.should == %w(area base br col hr img input link meta param embed)
227
+ expect(Tiny::HTML.void_tags).to eq(%w(area base br col hr img input link meta param embed))
228
228
  end
229
229
 
230
230
  Tiny::HTML.void_tags.each do |tag_name|
231
231
  describe tag_name do
232
232
  it 'sould autoclose' do
233
- tag(tag_name).should == "<#{tag_name} />"
234
- tag(tag_name.to_sym).should == "<#{tag_name} />"
233
+ expect(tag(tag_name)).to eq("<#{tag_name} />")
234
+ expect(tag(tag_name.to_sym)).to eq("<#{tag_name} />")
235
235
  end
236
236
 
237
237
  it 'should omit content' do
238
- tag(tag_name){ text 'hi' }.should == "<#{tag_name} />"
238
+ expect(tag(tag_name){ text 'hi' }).to eq("<#{tag_name} />")
239
239
  end
240
240
  end
241
241
  end
@@ -253,13 +253,13 @@ describe 'markup helpers' do
253
253
  ruby s samp script select small span strike strong style sub sup table
254
254
  tbody td textarea tfoot th thead time title tr tt u ul var
255
255
  )
256
- Tiny::HTML.content_tags.should == tags
256
+ expect(Tiny::HTML.content_tags).to eq(tags)
257
257
  end
258
258
 
259
259
  Tiny::HTML.content_tags.each do |tag_name|
260
260
  it "should not autoclose #{tag_name} if not empty" do
261
- tag(tag_name).should == "<#{tag_name}></#{tag_name}>"
262
- tag(tag_name.to_sym).should == "<#{tag_name}></#{tag_name}>"
261
+ expect(tag(tag_name)).to eq("<#{tag_name}></#{tag_name}>")
262
+ expect(tag(tag_name.to_sym)).to eq("<#{tag_name}></#{tag_name}>")
263
263
  end
264
264
  end
265
265
  end
@@ -273,10 +273,9 @@ describe 'markup helpers' do
273
273
  end
274
274
  end
275
275
 
276
- it { output.should have_css 'head', :count => 1 }
277
- it { output.should have_css 'head > title', :text => "Tiny Page!", :count => 1 }
278
- it { output.should have_css 'body', :count => 1 }
279
- it { output.should have_css 'body > h1', :text => "Hello Tiny!", :count => 1 }
276
+ it { expect(output).to have_title "Tiny Page!" }
277
+ it { expect(output).to have_css 'body', :count => 1 }
278
+ it { expect(output).to have_css 'body > h1', :text => "Hello Tiny!", :count => 1 }
280
279
  end
281
280
 
282
281
  describe 'dsl' do
@@ -285,25 +284,25 @@ describe 'markup helpers' do
285
284
  describe 'void tags' do
286
285
  Tiny::HTML.void_tags.each do |tag_name|
287
286
  it "should render '#{tag_name}'" do
288
- self.send(tag_name).should == "<#{tag_name} />"
287
+ expect(self.send(tag_name)).to eq("<#{tag_name} />")
289
288
  end
290
289
  end
291
290
 
292
291
  it "should render attributes" do
293
- link(:href => "some.css").should == '<link href="some.css" />'
292
+ expect(link(:href => "some.css")).to eq('<link href="some.css" />')
294
293
  end
295
294
  end
296
295
 
297
296
  describe 'content tags' do
298
297
  Tiny::HTML.content_tags.each do |tag_name|
299
298
  it "should render '#{tag_name}'" do
300
- self.send(tag_name).should == "<#{tag_name}></#{tag_name}>"
299
+ expect(self.send(tag_name)).to eq("<#{tag_name}></#{tag_name}>")
301
300
  end
302
301
  end
303
302
 
304
303
  it "should render content and attributes" do
305
- h1(:class => 'main') { text "Hello" }.should == %{<h1 class="main">\n Hello\n</h1>}
306
- h1("Hello", :class => 'main').should == %{<h1 class="main">Hello</h1>}
304
+ expect(h1(:class => 'main') { text "Hello" }).to eq(%{<h1 class="main">\n Hello\n</h1>})
305
+ expect(h1("Hello", :class => 'main')).to eq(%{<h1 class="main">Hello</h1>})
307
306
  end
308
307
  end
309
308
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'markup helpers' do
4
+ describe 'markup helpers', :type => :request do
5
5
  include Tiny::Helpers
6
6
 
7
7
  let(:output) do
@@ -15,7 +15,7 @@ describe 'markup helpers' do
15
15
  end
16
16
 
17
17
  def check_block &block
18
- erb_block?(block).should be_true
18
+ expect(erb_block?(block)).to be_truthy
19
19
  end
20
20
 
21
21
  it 'should determine block origin' do
@@ -23,29 +23,29 @@ describe 'markup helpers' do
23
23
  end
24
24
 
25
25
  it 'should capture erb' do
26
- Tilt['erb'].new { '<% mk = with_buffer("Tiny!") do |s| %>Hello <%= s %><% end %><%- mk.should == "Hello Tiny!" %>' }.render(self)
26
+ Tilt['erb'].new { '<% mk = with_buffer("Tiny!") do |s| %>Hello <%= s %><% end %><%- expect(mk).to eq "Hello Tiny!" %>' }.render(self)
27
27
  end
28
28
 
29
29
  it 'should emit tag' do
30
30
  @output = Tilt['erb'].new { '<%= tag(:div) %>' }.render(self)
31
- output.should have_css 'div', :count => 1
31
+ expect(output).to have_css 'div', :count => 1
32
32
  end
33
33
 
34
34
  it 'should not buffer multiple tags' do
35
35
  template = Tilt['erb'].new { '<%= yield %>' }
36
36
  output = template.render(self) { tag(:span); tag(:a) }
37
- output.should == '<a></a>'
37
+ expect(output).to eq('<a></a>')
38
38
  end
39
39
 
40
40
  it 'should buffer multiple tags inside with_buffer block' do
41
41
  template = Tilt['erb'].new { '<%= yield %>' }
42
42
  output = template.render(self) { with_buffer { tag(:span); tag(:a) } }
43
- output.should == "<span></span>\n<a></a>\n"
43
+ expect(output).to eq("<span></span>\n<a></a>\n")
44
44
  end
45
45
 
46
46
  it 'should concat erb block' do
47
47
  template = Tilt['erb'].new(:outvar => '@_out_buf') { '<%= span do %>Hello<% end %>' }
48
- template.render(self).should == "<span>\n Hello\n</span>\n"
48
+ expect(template.render(self)).to eq("<span>\n Hello\n</span>\n")
49
49
  end
50
50
 
51
51
  describe 'block passing' do
@@ -61,9 +61,9 @@ describe 'markup helpers' do
61
61
  ERB
62
62
  end.render(self)
63
63
  end
64
- it { output.should have_css 'div', :count => 1 }
65
- it { output.should have_css 'a', :count => 1 }
66
- it { output.should have_css 'div > a', :text => 'Hello' }
64
+ it { expect(output).to have_css 'div', :count => 1 }
65
+ it { expect(output).to have_css 'a', :count => 1 }
66
+ it { expect(output).to have_css 'div > a', :text => 'Hello' }
67
67
  end
68
68
 
69
69
  describe 'nested' do
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'markup helpers' do
4
+ describe 'markup helpers', :type => :request do
5
5
  include Tiny::Helpers
6
6
 
7
7
  let(:output) do
@@ -11,7 +11,7 @@ describe 'markup helpers' do
11
11
  describe 'tag' do
12
12
  it 'should emit tag' do
13
13
  @output = Tilt['haml'].new { '= tag(:div)' }.render(self)
14
- output.should have_css 'div', :count => 1
14
+ expect(output).to have_css 'div', :count => 1
15
15
  end
16
16
 
17
17
  it 'should emit haml block' do
@@ -21,7 +21,7 @@ describe 'markup helpers' do
21
21
  Hello
22
22
  HAML
23
23
  end.render(self)
24
- output.should have_css 'div', :text => "Hello", :count => 1
24
+ expect(output).to have_css 'div', :text => "Hello", :count => 1
25
25
  end
26
26
  end
27
27
 
@@ -36,9 +36,9 @@ describe 'markup helpers' do
36
36
  HAML
37
37
  end.render(self)
38
38
  end
39
- it { output.should have_css 'div', :count => 1 }
40
- it { output.should have_css 'a', :count => 1 }
41
- it { output.should have_css 'div > a', :text => 'Hello' }
39
+ it { expect(output).to have_css 'div', :count => 1 }
40
+ it { expect(output).to have_css 'a', :count => 1 }
41
+ it { expect(output).to have_css 'div > a', :text => 'Hello' }
42
42
  end
43
43
 
44
44
  describe 'nested' do
@@ -16,27 +16,27 @@ describe 'Rails compatibility', :type => :request do
16
16
  before do
17
17
  visit '/erb'
18
18
  end
19
- it_should_behave_like 'it renders my list'
19
+ it_behaves_like 'it renders my list'
20
20
  end
21
21
 
22
22
  describe 'using Tiny helpers from erb template' do
23
23
  before do
24
24
  visit '/erb_helpers'
25
25
  end
26
- it_should_behave_like 'it renders my list'
26
+ it_behaves_like 'it renders my list'
27
27
  end
28
28
 
29
29
  describe 'using Tiny from haml template' do
30
30
  before do
31
31
  visit '/haml'
32
32
  end
33
- it_should_behave_like 'it renders my list'
33
+ it_behaves_like 'it renders my list'
34
34
  end
35
35
 
36
36
  describe 'using Tiny helpers from haml template' do
37
37
  before do
38
38
  visit '/haml_helpers'
39
39
  end
40
- it_should_behave_like 'it renders my list'
40
+ it_behaves_like 'it renders my list'
41
41
  end
42
42
  end
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
  require "#{SUPPORT}/sinatra_app"
3
3
 
4
4
  describe 'Sinatra compatibility', :type => :request do
5
- include Rack::Test::Methods
6
-
7
5
  let(:output) do
8
6
  Capybara::Node::Simple.new(page.body)
9
7
  end
@@ -16,27 +14,27 @@ describe 'Sinatra compatibility', :type => :request do
16
14
  before do
17
15
  visit '/erb'
18
16
  end
19
- it_should_behave_like 'it renders my list'
17
+ it_behaves_like 'it renders my list'
20
18
  end
21
19
 
22
20
  describe 'using Tiny helpers from erb template' do
23
21
  before do
24
22
  visit '/erb_helpers'
25
23
  end
26
- it_should_behave_like 'it renders my list'
24
+ it_behaves_like 'it renders my list'
27
25
  end
28
26
 
29
27
  describe 'using Tiny from haml template' do
30
28
  before do
31
29
  visit '/haml'
32
30
  end
33
- it_should_behave_like 'it renders my list'
31
+ it_behaves_like 'it renders my list'
34
32
  end
35
33
 
36
34
  describe 'using Tiny helpers from haml template' do
37
35
  before do
38
36
  visit '/haml_helpers'
39
37
  end
40
- it_should_behave_like 'it renders my list'
38
+ it_behaves_like 'it renders my list'
41
39
  end
42
40
  end
@@ -12,32 +12,37 @@ require 'tiny'
12
12
  $:.unshift File.dirname(__FILE__)
13
13
  require 'support/list_helper'
14
14
 
15
+ RSpec.configure do |config|
16
+ config.include Capybara::DSL, type: :request
17
+ config.include Rack::Test::Methods, type: :request
18
+ end
19
+
15
20
  FIXTURES = "#{File.dirname __FILE__}/fixtures"
16
21
  SUPPORT = "#{File.dirname __FILE__}/support"
17
22
 
18
23
  shared_examples_for 'it renders my list' do
19
- it { output.should have_css 'ul', :count => 1 }
20
- it { output.should have_css 'li', :count => 3 }
21
- it { output.should have_css 'a', :count => 3 }
22
- it { output.should have_css 'span', :count => 3 }
23
- it { output.should have_css 'ul > li' }
24
- it { output.should have_css 'ul > li > a' }
25
- it { output.should have_css 'ul > li > a', :text => 'A' }
26
- it { output.should have_css 'ul > li > a > span', :text => '1' }
27
- it { output.should have_css 'ul > li > a', :text => 'B' }
28
- it { output.should have_css 'ul > li > a > span', :text => '2' }
29
- it { output.should have_css 'ul > li > a', :text => 'C' }
30
- it { output.should have_css 'ul > li > a > span', :text => '3' }
24
+ it { expect(output).to have_css 'ul', :count => 1 }
25
+ it { expect(output).to have_css 'li', :count => 3 }
26
+ it { expect(output).to have_css 'a', :count => 3 }
27
+ it { expect(output).to have_css 'span', :count => 3 }
28
+ it { expect(output).to have_css 'ul > li' }
29
+ it { expect(output).to have_css 'ul > li > a' }
30
+ it { expect(output).to have_css 'ul > li > a', :text => 'A' }
31
+ it { expect(output).to have_css 'ul > li > a > span', :text => '1' }
32
+ it { expect(output).to have_css 'ul > li > a', :text => 'B' }
33
+ it { expect(output).to have_css 'ul > li > a > span', :text => '2' }
34
+ it { expect(output).to have_css 'ul > li > a', :text => 'C' }
35
+ it { expect(output).to have_css 'ul > li > a > span', :text => '3' }
31
36
  end
32
37
 
33
38
  shared_examples_for 'it renders my form' do
34
- it { output.should have_css 'form', :count => 1 }
35
- it { output.should have_css 'form[action="/login"]', :count => 1 }
36
- it { output.should have_css 'form > fieldset', :count => 1 }
37
- it { output.should have_css 'form > fieldset > label', :count => 1}
38
- it { output.should have_css 'form > fieldset > label[for=email]', :text => 'Email', :count => 1}
39
- it { output.should have_css 'form > fieldset > input', :count => 1}
40
- it { output.should have_css 'form > fieldset > input#email[type=text][value="email@example.com"]', :count => 1 }
39
+ it { expect(output).to have_css 'form', :count => 1 }
40
+ it { expect(output).to have_css 'form[action="/login"]', :count => 1 }
41
+ it { expect(output).to have_css 'form > fieldset', :count => 1 }
42
+ it { expect(output).to have_css 'form > fieldset > label', :count => 1}
43
+ it { expect(output).to have_css 'form > fieldset > label[for=email]', :text => 'Email', :count => 1}
44
+ it { expect(output).to have_css 'form > fieldset > input', :count => 1}
45
+ it { expect(output).to have_css 'form > fieldset > input#email[type=text][value="email@example.com"]', :count => 1 }
41
46
  end
42
47
 
43
48
  class Renderer
@@ -16,8 +16,8 @@ describe Tiny::Widget do
16
16
  append! '<div></div>'
17
17
  end
18
18
  end.new.to_html
19
- output.should == "<div></div>\n"
20
- output.should be_html_safe
19
+ expect(output).to eq("<div></div>\n")
20
+ expect(output).to be_html_safe
21
21
  end
22
22
 
23
23
  it 'should output content with block' do
@@ -28,7 +28,7 @@ describe Tiny::Widget do
28
28
  append! "</div>"
29
29
  end
30
30
  end.new.to_html { text 'Hello' }
31
- output.should == "<div>\nHello\n</div>\n"
31
+ expect(output).to eq("<div>\nHello\n</div>\n")
32
32
  end
33
33
  end
34
34
 
@@ -36,16 +36,17 @@ describe Tiny::Widget do
36
36
  before do
37
37
  @output = Class.new(Tiny::Widget) do
38
38
  def markup
39
- head { title "Tiny Page!" }
40
- body { h1 "Hello Tiny!" }
39
+ html {
40
+ head { title "Tiny Page!" }
41
+ body { h1 "Hello Tiny!" }
42
+ }
41
43
  end
42
44
  end.new.to_html
43
45
  end
44
46
 
45
- it { output.should have_css 'head', :count => 1 }
46
- it { output.should have_css 'head > title', :text => "Tiny Page!", :count => 1 }
47
- it { output.should have_css 'body', :count => 1 }
48
- it { output.should have_css 'body > h1', :text => "Hello Tiny!", :count => 1 }
47
+ it { expect(output).to have_title "Tiny Page!" }
48
+ it { expect(output).to have_css 'body', :count => 1 }
49
+ it { expect(output).to have_css 'body > h1', :text => "Hello Tiny!", :count => 1 }
49
50
  end
50
51
 
51
52
  describe 'content from different methods' do
@@ -70,10 +71,10 @@ describe Tiny::Widget do
70
71
  end.new.to_html
71
72
  end
72
73
 
73
- it { output.should have_css 'div#notices', :count => 1 }
74
- it { output.should have_css 'div#notices > h1', :text => "Notices", :count => 1 }
75
- it { output.should have_css 'div#content', :count => 1 }
76
- it { output.should have_css 'div#content > h1', :text => "Content", :count => 1 }
74
+ it { expect(output).to have_css 'div#notices', :count => 1 }
75
+ it { expect(output).to have_css 'div#notices > h1', :text => "Notices", :count => 1 }
76
+ it { expect(output).to have_css 'div#content', :count => 1 }
77
+ it { expect(output).to have_css 'div#content > h1', :text => "Content", :count => 1 }
77
78
  end
78
79
 
79
80
  describe 'rendering a tag from outside' do
@@ -88,8 +89,8 @@ describe Tiny::Widget do
88
89
  end.new.to_html { tag :h1, @title }
89
90
  end
90
91
 
91
- it { output.should have_css 'div#content', :count => 1 }
92
- it { output.should have_css 'div#content > h1', :text => "Content", :count => 1 }
92
+ it { expect(output).to have_css 'div#content', :count => 1 }
93
+ it { expect(output).to have_css 'div#content > h1', :text => "Content", :count => 1 }
93
94
  end
94
95
 
95
96
  describe 'rendering a block from outside with concatenated tags' do
@@ -101,9 +102,9 @@ describe Tiny::Widget do
101
102
  end.new.to_html { tag(:h1, "Title"); tag(:p, "Content") }
102
103
  end
103
104
 
104
- it { output.should have_css 'div#content', :count => 1 }
105
- it { output.should have_css 'div#content > h1', :text => "Title", :count => 1 }
106
- it { output.should have_css 'div#content > p', :text => "Content", :count => 1 }
105
+ it { expect(output).to have_css 'div#content', :count => 1 }
106
+ it { expect(output).to have_css 'div#content > h1', :text => "Title", :count => 1 }
107
+ it { expect(output).to have_css 'div#content > p', :text => "Content", :count => 1 }
107
108
  end
108
109
 
109
110
  describe 'rendering an erb block' do
@@ -116,16 +117,16 @@ describe Tiny::Widget do
116
117
  @output = Tilt['erb'].new { '<%= widget.to_html do %><h1>Title</h1><p>Content</p><% end %>' }.render(self, :widget => widget)
117
118
  end
118
119
 
119
- it { output.should have_css 'div#content', :count => 1 }
120
- it { output.should have_css 'div#content > h1', :text => "Title", :count => 1 }
121
- it { output.should have_css 'div#content > p', :text => "Content", :count => 1 }
120
+ it { expect(output).to have_css 'div#content', :count => 1 }
121
+ it { expect(output).to have_css 'div#content > h1', :text => "Title", :count => 1 }
122
+ it { expect(output).to have_css 'div#content > p', :text => "Content", :count => 1 }
122
123
  end
123
124
 
124
125
  describe 'widget with no content overriden' do
125
126
  it 'should raise not implemented' do
126
- lambda do
127
+ expect do
127
128
  Class.new(Tiny::Widget).new.to_html
128
- end.should raise_error(NotImplementedError)
129
+ end.to raise_error(NotImplementedError)
129
130
  end
130
131
  end
131
132
 
@@ -18,15 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency 'tilt', '~> 1.3'
22
- s.add_runtime_dependency 'erubis', '~> 2.7'
23
- s.add_runtime_dependency 'escape_utils' # simple api
21
+ s.add_runtime_dependency 'tilt'
22
+ s.add_runtime_dependency 'erubis'
24
23
 
25
- s.add_development_dependency 'rspec', '~> 2.11'
26
- s.add_development_dependency 'nokogiri', '1.5.2'
27
- s.add_development_dependency 'capybara', '~> 1.1'
24
+ s.add_development_dependency 'rspec', '~> 3.1.0'
25
+ s.add_development_dependency 'capybara', '~> 2.4.0'
28
26
  s.add_development_dependency 'haml', '~> 3.1'
29
- s.add_development_dependency 'tilt', '~> 1.3'
30
- s.add_development_dependency 'sinatra' # I trust Sinatra
31
- s.add_development_dependency 'rails', '~> 3.2'
27
+ s.add_development_dependency 'sinatra'
28
+ s.add_development_dependency 'rails', '~> 4.1.0'
32
29
  end
metadata CHANGED
@@ -1,176 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
5
- prerelease:
4
+ version: 0.2.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Macario
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: tilt
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
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
- version: '1.3'
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: erubis
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '2.7'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
30
  requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '2.7'
46
- - !ruby/object:Gem::Dependency
47
- name: escape_utils
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
31
+ - - ">="
52
32
  - !ruby/object:Gem::Version
53
33
  version: '0'
54
34
  type: :runtime
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
- - - ! '>='
38
+ - - ">="
60
39
  - !ruby/object:Gem::Version
61
40
  version: '0'
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: rspec
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '2.11'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '2.11'
78
- - !ruby/object:Gem::Dependency
79
- name: nokogiri
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
44
  requirements:
83
- - - '='
45
+ - - "~>"
84
46
  - !ruby/object:Gem::Version
85
- version: 1.5.2
47
+ version: 3.1.0
86
48
  type: :development
87
49
  prerelease: false
88
50
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
51
  requirements:
91
- - - '='
52
+ - - "~>"
92
53
  - !ruby/object:Gem::Version
93
- version: 1.5.2
54
+ version: 3.1.0
94
55
  - !ruby/object:Gem::Dependency
95
56
  name: capybara
96
57
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
58
  requirements:
99
- - - ~>
59
+ - - "~>"
100
60
  - !ruby/object:Gem::Version
101
- version: '1.1'
61
+ version: 2.4.0
102
62
  type: :development
103
63
  prerelease: false
104
64
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
65
  requirements:
107
- - - ~>
66
+ - - "~>"
108
67
  - !ruby/object:Gem::Version
109
- version: '1.1'
68
+ version: 2.4.0
110
69
  - !ruby/object:Gem::Dependency
111
70
  name: haml
112
71
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
72
  requirements:
115
- - - ~>
73
+ - - "~>"
116
74
  - !ruby/object:Gem::Version
117
75
  version: '3.1'
118
76
  type: :development
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
79
  requirements:
123
- - - ~>
80
+ - - "~>"
124
81
  - !ruby/object:Gem::Version
125
82
  version: '3.1'
126
- - !ruby/object:Gem::Dependency
127
- name: tilt
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: '1.3'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: '1.3'
142
83
  - !ruby/object:Gem::Dependency
143
84
  name: sinatra
144
85
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
86
  requirements:
147
- - - ! '>='
87
+ - - ">="
148
88
  - !ruby/object:Gem::Version
149
89
  version: '0'
150
90
  type: :development
151
91
  prerelease: false
152
92
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
93
  requirements:
155
- - - ! '>='
94
+ - - ">="
156
95
  - !ruby/object:Gem::Version
157
96
  version: '0'
158
97
  - !ruby/object:Gem::Dependency
159
98
  name: rails
160
99
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
100
  requirements:
163
- - - ~>
101
+ - - "~>"
164
102
  - !ruby/object:Gem::Version
165
- version: '3.2'
103
+ version: 4.1.0
166
104
  type: :development
167
105
  prerelease: false
168
106
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
107
  requirements:
171
- - - ~>
108
+ - - "~>"
172
109
  - !ruby/object:Gem::Version
173
- version: '3.2'
110
+ version: 4.1.0
174
111
  description: Tiny is a tiny framework agnostic markup builder, useful for building
175
112
  view helpers on inclusion only adds three public methods, tag (for generating html
176
113
  tags), capture and concat, works as pure ruby and with erb and haml
@@ -180,8 +117,8 @@ executables: []
180
117
  extensions: []
181
118
  extra_rdoc_files: []
182
119
  files:
183
- - .gitignore
184
- - .rspec
120
+ - ".gitignore"
121
+ - ".rspec"
185
122
  - Gemfile
186
123
  - README.md
187
124
  - Rakefile
@@ -210,27 +147,26 @@ files:
210
147
  - tiny.gemspec
211
148
  homepage: ''
212
149
  licenses: []
150
+ metadata: {}
213
151
  post_install_message:
214
152
  rdoc_options: []
215
153
  require_paths:
216
154
  - lib
217
155
  required_ruby_version: !ruby/object:Gem::Requirement
218
- none: false
219
156
  requirements:
220
- - - ! '>='
157
+ - - ">="
221
158
  - !ruby/object:Gem::Version
222
159
  version: '0'
223
160
  required_rubygems_version: !ruby/object:Gem::Requirement
224
- none: false
225
161
  requirements:
226
- - - ! '>='
162
+ - - ">="
227
163
  - !ruby/object:Gem::Version
228
164
  version: '0'
229
165
  requirements: []
230
166
  rubyforge_project: tiny
231
- rubygems_version: 1.8.24
167
+ rubygems_version: 2.2.2
232
168
  signing_key:
233
- specification_version: 3
169
+ specification_version: 4
234
170
  summary: Framework agnostic markup builder, useful for building view helpers or as
235
171
  a micro templating dsl, plays nice with erb and haml
236
172
  test_files: