padrino-helpers 0.12.8.1 → 0.12.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +13 -5
  2. data/Rakefile +1 -5
  3. data/lib/padrino-helpers.rb +2 -1
  4. data/lib/padrino-helpers/asset_tag_helpers.rb +16 -4
  5. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +39 -1
  6. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
  7. data/lib/padrino-helpers/form_helpers.rb +220 -1
  8. data/lib/padrino-helpers/form_helpers/options.rb +7 -5
  9. data/lib/padrino-helpers/output_helpers.rb +1 -1
  10. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
  11. data/lib/padrino-helpers/output_helpers/erb_handler.rb +2 -1
  12. data/lib/padrino-helpers/render_helpers.rb +23 -2
  13. data/lib/padrino-helpers/tag_helpers.rb +13 -0
  14. data/lib/padrino/rendering.rb +2 -1
  15. data/lib/padrino/rendering/erb_template.rb +12 -0
  16. data/lib/padrino/rendering/erubis_template.rb +1 -1
  17. data/padrino-helpers.gemspec +1 -1
  18. data/test/fixtures/markup_app/views/form_for.erb +28 -0
  19. data/test/fixtures/markup_app/views/form_for.haml +22 -0
  20. data/test/fixtures/markup_app/views/form_for.slim +21 -0
  21. data/test/fixtures/markup_app/views/form_tag.erb +21 -0
  22. data/test/fixtures/markup_app/views/form_tag.haml +14 -0
  23. data/test/fixtures/markup_app/views/form_tag.slim +14 -0
  24. data/test/helper.rb +14 -68
  25. data/test/test_asset_tag_helpers.rb +106 -93
  26. data/test/test_form_builder.rb +691 -450
  27. data/test/test_form_helpers.rb +770 -457
  28. data/test/test_format_helpers.rb +17 -37
  29. data/test/test_helpers.rb +8 -0
  30. data/test/test_output_helpers.rb +72 -72
  31. data/test/test_render_helpers.rb +142 -100
  32. data/test/test_rendering.rb +30 -6
  33. data/test/test_tag_helpers.rb +41 -39
  34. metadata +37 -23
@@ -151,6 +151,18 @@ describe "Rendering" do
151
151
  assert_equal 'layout404 file', body
152
152
  end
153
153
 
154
+ it 'should work with set content type not contained in rack-types' do
155
+ create_view "index.md.erb", "Hello"
156
+ mock_app do
157
+ get("/") {
158
+ content_type "text/x-markdown; charset=UTF-8"
159
+ render "index.erb", { :layout => nil }
160
+ }
161
+ end
162
+ get "/"
163
+ assert_equal "Hello", body
164
+ end
165
+
154
166
  it 'should not use html file when DEFAULT_RENDERING_OPTIONS[:strict_format] == true' do
155
167
  create_layout :foo, "html file", :format => :html
156
168
 
@@ -572,12 +584,14 @@ describe "Rendering" do
572
584
 
573
585
  it 'should renders erb with blocks' do
574
586
  mock_app do
575
- def container
576
- @_out_buf << "THIS."
577
- yield
578
- @_out_buf << "SPARTA!"
587
+ helpers do
588
+ def container
589
+ @_out_buf << "THIS."
590
+ yield
591
+ @_out_buf << "SPARTA!"
592
+ end
593
+ def is; "IS."; end
579
594
  end
580
- def is; "IS."; end
581
595
  get '/' do
582
596
  render :erb, '<% container do %> <%= is %> <% end %>'
583
597
  end
@@ -675,7 +689,7 @@ describe "Rendering" do
675
689
  class Application < Sinatra::Base
676
690
  register Padrino::Rendering
677
691
  get '/' do
678
- render :post, :views => File.dirname(__FILE__)+'/fixtures/apps/views/blog'
692
+ render :post, :views => File.dirname(__FILE__)+'/fixtures/apps/views/blog'
679
693
  end
680
694
  end
681
695
  @app = Application.new
@@ -736,4 +750,14 @@ describe "Rendering" do
736
750
  assert_equal "application/xml;charset=utf-8", response['Content-Type']
737
751
  end
738
752
  end
753
+
754
+ describe 'rendering with helpers that use render' do
755
+ %W{erb haml slim}.each do |engine|
756
+ it "should work with #{engine}" do
757
+ @app = RenderDemo
758
+ get "/double_dive_#{engine}"
759
+ assert_response_has_tag '.outer .wrapper form .inner .core'
760
+ end
761
+ end
762
+ end
739
763
  end
@@ -8,27 +8,29 @@ describe "TagHelpers" do
8
8
 
9
9
  describe 'for #tag method' do
10
10
  it 'should support tags with no content no attributes' do
11
- assert_has_tag(:br) { tag(:br) }
11
+ assert_html_has_tag(tag(:br), :br)
12
12
  end
13
13
 
14
14
  it 'should support tags with no content with attributes' do
15
15
  actual_html = tag(:br, :style => 'clear:both', :class => 'yellow')
16
- assert_has_tag(:br, :class => 'yellow', :style=>'clear:both') { actual_html }
16
+ assert_html_has_tag(actual_html, :br, :class => 'yellow', :style=>'clear:both')
17
17
  end
18
18
 
19
19
  it 'should support selected attribute by using "selected" if true' do
20
20
  actual_html = tag(:option, :selected => true)
21
- assert_has_tag('option', :selected => 'selected') { actual_html }
21
+ # fix nokogiri 1.6.8 on jRuby
22
+ actual_html = content_tag(:select, actual_html)
23
+ assert_html_has_tag(actual_html, 'option', :selected => 'selected')
22
24
  end
23
25
 
24
26
  it 'should support data attributes' do
25
27
  actual_html = tag(:a, :data => { :remote => true, :method => 'post'})
26
- assert_has_tag(:a, 'data-remote' => 'true', 'data-method' => 'post') { actual_html }
28
+ assert_html_has_tag(actual_html, :a, 'data-remote' => 'true', 'data-method' => 'post')
27
29
  end
28
30
 
29
31
  it 'should support nested attributes' do
30
32
  actual_html = tag(:div, :data => {:dojo => {:type => 'dijit.form.TextBox', :props => 'readOnly: true'}})
31
- assert_has_tag(:div, 'data-dojo-type' => 'dijit.form.TextBox', 'data-dojo-props' => 'readOnly: true') { actual_html }
33
+ assert_html_has_tag(actual_html, :div, 'data-dojo-type' => 'dijit.form.TextBox', 'data-dojo-props' => 'readOnly: true')
32
34
  end
33
35
 
34
36
  it 'should support open tags' do
@@ -45,87 +47,87 @@ describe "TagHelpers" do
45
47
  describe 'for #content_tag method' do
46
48
  it 'should support tags with content as parameter' do
47
49
  actual_html = content_tag(:p, "Demo", :class => 'large', :id => 'thing')
48
- assert_has_tag('p.large#thing', :content => "Demo") { actual_html }
50
+ assert_html_has_tag(actual_html, 'p.large#thing', :content => "Demo")
49
51
  end
50
52
 
51
53
  it 'should support tags with content as block' do
52
54
  actual_html = content_tag(:p, :class => 'large', :id => 'star') { "Demo" }
53
- assert_has_tag('p.large#star', :content => "Demo") { actual_html }
55
+ assert_html_has_tag(actual_html, 'p.large#star', :content => "Demo")
54
56
  end
55
57
 
56
58
  it 'should escape non-html-safe content' do
57
59
  actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
58
- assert_has_tag('p.large#star') { actual_html }
60
+ assert_html_has_tag(actual_html, 'p.large#star')
59
61
  assert_match('&lt;&gt;', actual_html)
60
62
  end
61
63
 
62
64
  it 'should not escape html-safe content' do
63
65
  actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
64
- assert_has_tag('p.large#star', :content => "<>") { actual_html }
66
+ assert_html_has_tag(actual_html, 'p.large#star', :content => "<>")
65
67
  end
66
68
 
67
69
  it 'should convert to a string if the content is not a string' do
68
70
  actual_html = content_tag(:p, 97)
69
- assert_has_tag('p', :content => "97") { actual_html }
71
+ assert_html_has_tag(actual_html, 'p', :content => "97")
70
72
  end
71
73
 
72
74
  it 'should support tags with erb' do
73
- visit '/erb/content_tag'
74
- assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
75
- assert_have_selector :p, :content => "Test 2"
76
- assert_have_selector :p, :content => "Test 3"
77
- assert_have_selector :p, :content => "Test 4"
78
- assert_have_selector :p, :content => "one"
79
- assert_have_selector :p, :content => "two"
80
- assert_have_no_selector :p, :content => "failed"
75
+ get "/erb/content_tag"
76
+ assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
77
+ assert_response_has_tag :p, :content => "Test 2"
78
+ assert_response_has_tag :p, :content => "Test 3"
79
+ assert_response_has_tag :p, :content => "Test 4"
80
+ assert_response_has_tag :p, :content => "one"
81
+ assert_response_has_tag :p, :content => "two"
82
+ assert_response_has_no_tag :p, :content => "failed"
81
83
  end
82
84
 
83
85
  it 'should support tags with haml' do
84
- visit '/haml/content_tag'
85
- assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
86
- assert_have_selector :p, :content => "Test 2"
87
- assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
88
- assert_have_selector :p, :content => "Test 4"
89
- assert_have_selector :p, :content => "one"
90
- assert_have_selector :p, :content => "two"
91
- assert_have_no_selector :p, :content => "failed"
86
+ get "/haml/content_tag"
87
+ assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
88
+ assert_response_has_tag :p, :content => "Test 2"
89
+ assert_response_has_tag :p, :content => "Test 3", :class => 'test', :id => 'test3'
90
+ assert_response_has_tag :p, :content => "Test 4"
91
+ assert_response_has_tag :p, :content => "one"
92
+ assert_response_has_tag :p, :content => "two"
93
+ assert_response_has_no_tag :p, :content => "failed"
92
94
  end
93
95
 
94
96
  it 'should support tags with slim' do
95
- visit '/slim/content_tag'
96
- assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
97
- assert_have_selector :p, :content => "Test 2"
98
- assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
99
- assert_have_selector :p, :content => "Test 4"
100
- assert_have_selector :p, :content => "one"
101
- assert_have_selector :p, :content => "two"
102
- assert_have_no_selector :p, :content => "failed"
97
+ get "/slim/content_tag"
98
+ assert_response_has_tag :p, :content => "Test 1", :class => 'test', :id => 'test1'
99
+ assert_response_has_tag :p, :content => "Test 2"
100
+ assert_response_has_tag :p, :content => "Test 3", :class => 'test', :id => 'test3'
101
+ assert_response_has_tag :p, :content => "Test 4"
102
+ assert_response_has_tag :p, :content => "one"
103
+ assert_response_has_tag :p, :content => "two"
104
+ assert_response_has_no_tag :p, :content => "failed"
103
105
  end
104
106
  end
105
107
 
106
108
  describe 'for #input_tag method' do
107
109
  it 'should support field with type' do
108
- assert_has_tag('input[type=text]') { input_tag(:text) }
110
+ assert_html_has_tag(input_tag(:text), 'input[type=text]')
109
111
  end
110
112
 
111
113
  it 'should support field with type and options' do
112
114
  actual_html = input_tag(:text, :class => "first", :id => 'texter')
113
- assert_has_tag('input.first#texter[type=text]') { actual_html }
115
+ assert_html_has_tag(actual_html, 'input.first#texter[type=text]')
114
116
  end
115
117
 
116
118
  it 'should support checked attribute by using "checked" if true' do
117
119
  actual_html = input_tag(:checkbox, :checked => true)
118
- assert_has_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
120
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
119
121
  end
120
122
 
121
123
  it 'should remove checked attribute if false' do
122
124
  actual_html = input_tag(:checkbox, :checked => false)
123
- assert_has_no_tag('input[type=checkbox][checked=false]') { actual_html }
125
+ assert_html_has_no_tag(actual_html, 'input[type=checkbox][checked=false]')
124
126
  end
125
127
 
126
128
  it 'should support disabled attribute by using "disabled" if true' do
127
129
  actual_html = input_tag(:checkbox, :disabled => true)
128
- assert_has_tag('input[type=checkbox]', :disabled => 'disabled') { actual_html }
130
+ assert_html_has_tag(actual_html, 'input[type=checkbox]', :disabled => 'disabled')
129
131
  end
130
132
  end
131
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.8.1
4
+ version: 0.12.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-06 00:00:00.000000000 Z
14
+ date: 2018-02-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,48 +19,62 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.8.1
22
+ version: 0.12.9
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.12.8.1
29
+ version: 0.12.9
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: tilt
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - ! '>='
35
35
  - !ruby/object:Gem::Version
36
- version: 1.4.1
36
+ version: !binary |-
37
+ MS40LjE=
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: !binary |-
41
+ Mw==
37
42
  type: :runtime
38
43
  prerelease: false
39
44
  version_requirements: !ruby/object:Gem::Requirement
40
45
  requirements:
41
- - - "~>"
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: !binary |-
49
+ MS40LjE=
50
+ - - <
42
51
  - !ruby/object:Gem::Version
43
- version: 1.4.1
52
+ version: !binary |-
53
+ Mw==
44
54
  - !ruby/object:Gem::Dependency
45
55
  name: i18n
46
56
  requirement: !ruby/object:Gem::Requirement
47
57
  requirements:
48
- - - "~>"
58
+ - - ~>
49
59
  - !ruby/object:Gem::Version
50
- version: '0.6'
51
- - - ">="
60
+ version: !binary |-
61
+ MC42
62
+ - - ! '>='
52
63
  - !ruby/object:Gem::Version
53
- version: 0.6.7
64
+ version: !binary |-
65
+ MC42Ljc=
54
66
  type: :runtime
55
67
  prerelease: false
56
68
  version_requirements: !ruby/object:Gem::Requirement
57
69
  requirements:
58
- - - "~>"
70
+ - - ~>
59
71
  - !ruby/object:Gem::Version
60
- version: '0.6'
61
- - - ">="
72
+ version: !binary |-
73
+ MC42
74
+ - - ! '>='
62
75
  - !ruby/object:Gem::Version
63
- version: 0.6.7
76
+ version: !binary |-
77
+ MC42Ljc=
64
78
  description: Tag helpers, asset helpers, form helpers, form builders and many more
65
79
  helpers for padrino
66
80
  email: padrinorb@gmail.com
@@ -69,9 +83,9 @@ extensions: []
69
83
  extra_rdoc_files:
70
84
  - README.rdoc
71
85
  files:
72
- - ".document"
73
- - ".gitignore"
74
- - ".yardopts"
86
+ - .document
87
+ - .gitignore
88
+ - .yardopts
75
89
  - LICENSE.txt
76
90
  - README.rdoc
77
91
  - Rakefile
@@ -225,22 +239,22 @@ licenses:
225
239
  metadata: {}
226
240
  post_install_message:
227
241
  rdoc_options:
228
- - "--charset=UTF-8"
242
+ - --charset=UTF-8
229
243
  require_paths:
230
244
  - lib
231
245
  required_ruby_version: !ruby/object:Gem::Requirement
232
246
  requirements:
233
- - - ">="
247
+ - - ! '>='
234
248
  - !ruby/object:Gem::Version
235
249
  version: '0'
236
250
  required_rubygems_version: !ruby/object:Gem::Requirement
237
251
  requirements:
238
- - - ">="
252
+ - - ! '>='
239
253
  - !ruby/object:Gem::Version
240
254
  version: 1.3.6
241
255
  requirements: []
242
256
  rubyforge_project: padrino-helpers
243
- rubygems_version: 2.5.1
257
+ rubygems_version: 2.6.14
244
258
  signing_key:
245
259
  specification_version: 4
246
260
  summary: Helpers for padrino