padrino-helpers 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/lib/padrino-helpers.rb +16 -0
- data/lib/padrino-helpers/asset_tag_helpers.rb +97 -0
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +139 -0
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +37 -0
- data/lib/padrino-helpers/form_helpers.rb +194 -0
- data/lib/padrino-helpers/format_helpers.rb +74 -0
- data/lib/padrino-helpers/output_helpers.rb +98 -0
- data/lib/padrino-helpers/render_helpers.rb +63 -0
- data/lib/padrino-helpers/tag_helpers.rb +42 -0
- data/test/active_support_helpers.rb +7 -0
- data/test/fixtures/markup_app/app.rb +61 -0
- data/test/fixtures/markup_app/views/capture_concat.erb +14 -0
- data/test/fixtures/markup_app/views/capture_concat.haml +13 -0
- data/test/fixtures/markup_app/views/content_for.erb +11 -0
- data/test/fixtures/markup_app/views/content_for.haml +9 -0
- data/test/fixtures/markup_app/views/content_tag.erb +11 -0
- data/test/fixtures/markup_app/views/content_tag.haml +9 -0
- data/test/fixtures/markup_app/views/fields_for.erb +8 -0
- data/test/fixtures/markup_app/views/fields_for.haml +6 -0
- data/test/fixtures/markup_app/views/form_for.erb +56 -0
- data/test/fixtures/markup_app/views/form_for.haml +47 -0
- data/test/fixtures/markup_app/views/form_tag.erb +57 -0
- data/test/fixtures/markup_app/views/form_tag.haml +45 -0
- data/test/fixtures/markup_app/views/link_to.erb +5 -0
- data/test/fixtures/markup_app/views/link_to.haml +4 -0
- data/test/fixtures/markup_app/views/mail_to.erb +3 -0
- data/test/fixtures/markup_app/views/mail_to.haml +3 -0
- data/test/fixtures/render_app/app.rb +53 -0
- data/test/fixtures/render_app/views/erb/test.erb +1 -0
- data/test/fixtures/render_app/views/haml/test.haml +1 -0
- data/test/fixtures/render_app/views/template/_user.haml +7 -0
- data/test/fixtures/render_app/views/template/haml_template.haml +1 -0
- data/test/fixtures/render_app/views/template/some_template.haml +2 -0
- data/test/helper.rb +73 -0
- data/test/test_asset_tag_helpers.rb +127 -0
- data/test/test_form_builder.rb +611 -0
- data/test/test_form_helpers.rb +406 -0
- data/test/test_format_helpers.rb +96 -0
- data/test/test_output_helpers.rb +63 -0
- data/test/test_render_helpers.rb +78 -0
- data/test/test_tag_helpers.rb +73 -0
- metadata +174 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require File.dirname(__FILE__) + '/fixtures/markup_app/app'
|
3
|
+
|
4
|
+
class TestOutputHelpers < Test::Unit::TestCase
|
5
|
+
def app
|
6
|
+
MarkupDemo.tap { |app| app.set :environment, :test }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'for #content_for method' do
|
10
|
+
should 'work for erb templates' do
|
11
|
+
visit '/erb/content_for'
|
12
|
+
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
|
13
|
+
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
|
14
|
+
end
|
15
|
+
|
16
|
+
should "work for haml templates" do
|
17
|
+
visit '/haml/content_for'
|
18
|
+
assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
|
19
|
+
assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'for #capture_html method' do
|
24
|
+
should "work for erb templates" do
|
25
|
+
visit '/erb/capture_concat'
|
26
|
+
assert_have_selector 'p span', :content => "Captured Line 1"
|
27
|
+
assert_have_selector 'p span', :content => "Captured Line 2"
|
28
|
+
end
|
29
|
+
|
30
|
+
should "work for haml templates" do
|
31
|
+
visit '/haml/capture_concat'
|
32
|
+
assert_have_selector 'p span', :content => "Captured Line 1"
|
33
|
+
assert_have_selector 'p span', :content => "Captured Line 2"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'for #concat_content method' do
|
38
|
+
should "work for erb templates" do
|
39
|
+
visit '/erb/capture_concat'
|
40
|
+
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
|
41
|
+
end
|
42
|
+
|
43
|
+
should "work for haml templates" do
|
44
|
+
visit '/haml/capture_concat'
|
45
|
+
assert_have_selector 'p', :content => "Concat Line 3", :count => 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'for #block_is_template?' do
|
50
|
+
should "work for erb templates" do
|
51
|
+
visit '/erb/capture_concat'
|
52
|
+
assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template'
|
53
|
+
# TODO Get ERB template detection working (fix block_is_erb? method)
|
54
|
+
# assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
55
|
+
end
|
56
|
+
|
57
|
+
should "work for haml templates" do
|
58
|
+
visit '/haml/capture_concat'
|
59
|
+
assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template'
|
60
|
+
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require File.dirname(__FILE__) + '/fixtures/render_app/app'
|
3
|
+
|
4
|
+
class TestRenderHelpers < Test::Unit::TestCase
|
5
|
+
def app
|
6
|
+
RenderDemo.tap { |app| app.set :environment, :test }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'for #haml_template method' do
|
10
|
+
setup { visit '/render_haml' }
|
11
|
+
should('render template properly') do
|
12
|
+
assert_have_selector "h1", :content => "This is a haml template!"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'for #erb_template method' do
|
17
|
+
setup { visit '/render_erb' }
|
18
|
+
should('render template properly') do
|
19
|
+
assert_have_selector "h1", :content => "This is a erb template!"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'for #render_template method with explicit engine' do
|
24
|
+
setup { visit '/render_template/haml' }
|
25
|
+
should('render template properly') do
|
26
|
+
assert_have_selector "h1", :content => "This is a haml template sent from render_template!"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'for #render_template method without explicit engine' do
|
31
|
+
setup { visit '/render_template' }
|
32
|
+
should('render template properly') do
|
33
|
+
assert_have_selector "h1", :content => "This is a haml template which was detected!"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'for #partial method and object' do
|
38
|
+
setup { visit '/partial/object' }
|
39
|
+
should "render partial html with object" do
|
40
|
+
assert_have_selector "h1", :content => "User name is John"
|
41
|
+
end
|
42
|
+
should "have no counter index for single item" do
|
43
|
+
assert_have_no_selector "p", :content => "My counter is 1", :count => 1
|
44
|
+
end
|
45
|
+
should "include extra locals information" do
|
46
|
+
assert_have_selector 'p', :content => "Extra is bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'for #partial method and collection' do
|
51
|
+
setup { visit '/partial/collection' }
|
52
|
+
should "render partial html with collection" do
|
53
|
+
assert_have_selector "h1", :content => "User name is John"
|
54
|
+
assert_have_selector "h1", :content => "User name is Billy"
|
55
|
+
end
|
56
|
+
should "include counter which contains item index" do
|
57
|
+
assert_have_selector "p", :content => "My counter is 1"
|
58
|
+
assert_have_selector "p", :content => "My counter is 2"
|
59
|
+
end
|
60
|
+
should "include extra locals information" do
|
61
|
+
assert_have_selector 'p', :content => "Extra is bar"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'for #partial method and locals' do
|
66
|
+
setup { visit '/partial/locals' }
|
67
|
+
should "render partial html with locals" do
|
68
|
+
assert_have_selector "h1", :content => "User name is John"
|
69
|
+
end
|
70
|
+
should "have no counter index for single item" do
|
71
|
+
assert_have_no_selector "p", :content => "My counter is 1", :count => 1
|
72
|
+
end
|
73
|
+
should "include extra locals information" do
|
74
|
+
assert_have_selector 'p', :content => "Extra is bar"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require File.dirname(__FILE__) + '/fixtures/markup_app/app'
|
3
|
+
|
4
|
+
class TestTagHelpers < Test::Unit::TestCase
|
5
|
+
def app
|
6
|
+
MarkupDemo.tap { |app| app.set :environment, :test }
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'for #tag method' do
|
10
|
+
should("support tags with no content no attributes") do
|
11
|
+
assert_has_tag(:br) { tag(:br) }
|
12
|
+
end
|
13
|
+
should("support tags with no content with attributes") do
|
14
|
+
actual_html = tag(:br, :style => 'clear:both', :class => 'yellow')
|
15
|
+
assert_has_tag(:br, :class => 'yellow', :style=>'clear:both') { actual_html }
|
16
|
+
end
|
17
|
+
should "support selected attribute by using 'selected' if true" do
|
18
|
+
actual_html = tag(:option, :selected => true)
|
19
|
+
assert_has_tag('option', :selected => 'selected') { actual_html }
|
20
|
+
end
|
21
|
+
should "support tags with content no attributes" do
|
22
|
+
assert_has_tag(:p, :content => "Demo String") { tag(:p, :content => "Demo String") }
|
23
|
+
end
|
24
|
+
should "support tags with content and attributes" do
|
25
|
+
actual_html = tag(:p, :content => "Demo", :class => 'large', :id => 'intro')
|
26
|
+
assert_has_tag('p#intro.large', :content => "Demo") { actual_html }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'for #content_tag method' do
|
31
|
+
should "support tags with content as parameter" do
|
32
|
+
actual_html = content_tag(:p, "Demo", :class => 'large', :id => 'thing')
|
33
|
+
assert_has_tag('p.large#thing', :content => "Demo") { actual_html }
|
34
|
+
end
|
35
|
+
should "support tags with content as block" do
|
36
|
+
actual_html = content_tag(:p, :class => 'large', :id => 'star') { "Demo" }
|
37
|
+
assert_has_tag('p.large#star', :content => "Demo") { actual_html }
|
38
|
+
end
|
39
|
+
should "support tags with erb" do
|
40
|
+
visit '/erb/content_tag'
|
41
|
+
assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
|
42
|
+
assert_have_selector :p, :content => "Test 2"
|
43
|
+
assert_have_selector :p, :content => "Test 3"
|
44
|
+
assert_have_selector :p, :content => "Test 4"
|
45
|
+
end
|
46
|
+
should "support tags with haml" do
|
47
|
+
visit '/haml/content_tag'
|
48
|
+
assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
|
49
|
+
assert_have_selector :p, :content => "Test 2"
|
50
|
+
assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
|
51
|
+
assert_have_selector :p, :content => "Test 4"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'for #input_tag method' do
|
56
|
+
should "support field with type" do
|
57
|
+
assert_has_tag('input[type=text]') { input_tag(:text) }
|
58
|
+
end
|
59
|
+
should "support field with type and options" do
|
60
|
+
actual_html = input_tag(:text, :class => "first", :id => 'texter')
|
61
|
+
assert_has_tag('input.first#texter[type=text]') { actual_html }
|
62
|
+
end
|
63
|
+
should "support checked attribute by using 'checked' if true" do
|
64
|
+
actual_html = input_tag(:checkbox, :checked => true)
|
65
|
+
assert_has_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
66
|
+
end
|
67
|
+
should "support disabled attribute by using 'disabled' if true" do
|
68
|
+
actual_html = input_tag(:checkbox, :disabled => true)
|
69
|
+
assert_has_tag('input[type=checkbox]', :disabled => 'disabled') { actual_html }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: padrino-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Padrino Team
|
8
|
+
- Nathan Esquenazi
|
9
|
+
- Davide D'Agostino
|
10
|
+
- Arthur Chiu
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-11-16 00:00:00 -08:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: sinatra
|
20
|
+
type: :runtime
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.2
|
27
|
+
version:
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: haml
|
30
|
+
type: :development
|
31
|
+
version_requirement:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.2.1
|
37
|
+
version:
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: shoulda
|
40
|
+
type: :development
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
type: :development
|
51
|
+
version_requirement:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.9.7
|
57
|
+
version:
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
type: :development
|
61
|
+
version_requirement:
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.5.0
|
67
|
+
version:
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: webrat
|
70
|
+
type: :development
|
71
|
+
version_requirement:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.5.1
|
77
|
+
version:
|
78
|
+
description: Tag helpers, asset helpers, form helpers, form builders and many more helpers for padrino
|
79
|
+
email: nesquena@gmail.com
|
80
|
+
executables: []
|
81
|
+
|
82
|
+
extensions: []
|
83
|
+
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE
|
86
|
+
- README.rdoc
|
87
|
+
files:
|
88
|
+
- .document
|
89
|
+
- .gitignore
|
90
|
+
- LICENSE
|
91
|
+
- README.rdoc
|
92
|
+
- Rakefile
|
93
|
+
- VERSION
|
94
|
+
- lib/padrino-helpers.rb
|
95
|
+
- lib/padrino-helpers/asset_tag_helpers.rb
|
96
|
+
- lib/padrino-helpers/form_builder/abstract_form_builder.rb
|
97
|
+
- lib/padrino-helpers/form_builder/standard_form_builder.rb
|
98
|
+
- lib/padrino-helpers/form_helpers.rb
|
99
|
+
- lib/padrino-helpers/format_helpers.rb
|
100
|
+
- lib/padrino-helpers/output_helpers.rb
|
101
|
+
- lib/padrino-helpers/render_helpers.rb
|
102
|
+
- lib/padrino-helpers/tag_helpers.rb
|
103
|
+
- test/active_support_helpers.rb
|
104
|
+
- test/fixtures/markup_app/app.rb
|
105
|
+
- test/fixtures/markup_app/views/capture_concat.erb
|
106
|
+
- test/fixtures/markup_app/views/capture_concat.haml
|
107
|
+
- test/fixtures/markup_app/views/content_for.erb
|
108
|
+
- test/fixtures/markup_app/views/content_for.haml
|
109
|
+
- test/fixtures/markup_app/views/content_tag.erb
|
110
|
+
- test/fixtures/markup_app/views/content_tag.haml
|
111
|
+
- test/fixtures/markup_app/views/fields_for.erb
|
112
|
+
- test/fixtures/markup_app/views/fields_for.haml
|
113
|
+
- test/fixtures/markup_app/views/form_for.erb
|
114
|
+
- test/fixtures/markup_app/views/form_for.haml
|
115
|
+
- test/fixtures/markup_app/views/form_tag.erb
|
116
|
+
- test/fixtures/markup_app/views/form_tag.haml
|
117
|
+
- test/fixtures/markup_app/views/link_to.erb
|
118
|
+
- test/fixtures/markup_app/views/link_to.haml
|
119
|
+
- test/fixtures/markup_app/views/mail_to.erb
|
120
|
+
- test/fixtures/markup_app/views/mail_to.haml
|
121
|
+
- test/fixtures/render_app/app.rb
|
122
|
+
- test/fixtures/render_app/views/erb/test.erb
|
123
|
+
- test/fixtures/render_app/views/haml/test.haml
|
124
|
+
- test/fixtures/render_app/views/template/_user.haml
|
125
|
+
- test/fixtures/render_app/views/template/haml_template.haml
|
126
|
+
- test/fixtures/render_app/views/template/some_template.haml
|
127
|
+
- test/helper.rb
|
128
|
+
- test/test_asset_tag_helpers.rb
|
129
|
+
- test/test_form_builder.rb
|
130
|
+
- test/test_form_helpers.rb
|
131
|
+
- test/test_format_helpers.rb
|
132
|
+
- test/test_output_helpers.rb
|
133
|
+
- test/test_render_helpers.rb
|
134
|
+
- test/test_tag_helpers.rb
|
135
|
+
has_rdoc: true
|
136
|
+
homepage: http://github.com/padrino/padrino-helpers
|
137
|
+
licenses: []
|
138
|
+
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options:
|
141
|
+
- --charset=UTF-8
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: "0"
|
149
|
+
version:
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: "0"
|
155
|
+
version:
|
156
|
+
requirements: []
|
157
|
+
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 1.3.5
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: Helpers for padrino
|
163
|
+
test_files:
|
164
|
+
- test/active_support_helpers.rb
|
165
|
+
- test/fixtures/markup_app/app.rb
|
166
|
+
- test/fixtures/render_app/app.rb
|
167
|
+
- test/helper.rb
|
168
|
+
- test/test_asset_tag_helpers.rb
|
169
|
+
- test/test_form_builder.rb
|
170
|
+
- test/test_form_helpers.rb
|
171
|
+
- test/test_format_helpers.rb
|
172
|
+
- test/test_output_helpers.rb
|
173
|
+
- test/test_render_helpers.rb
|
174
|
+
- test/test_tag_helpers.rb
|