twilson63-sinatra-formhelpers 0.3.0 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/sinatra/formhelpers.rb +5 -4
- data/sinatra-formhelpers.gemspec +6 -6
- data/test/formhelpers_test.rb +21 -1
- metadata +3 -3
data/VERSION.yml
CHANGED
data/lib/sinatra/formhelpers.rb
CHANGED
|
@@ -20,8 +20,8 @@ module Sinatra
|
|
|
20
20
|
tag :a, content, options.merge(:href => href)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def label(obj,field, options={})
|
|
24
|
-
tag :label, field.to_s.titleize, options.merge(:for => "#{obj}_#{field}")
|
|
23
|
+
def label(obj, field, display = "", options={})
|
|
24
|
+
tag :label, display.blank? ? field.to_s.titleize : display, options.merge(:for => "#{obj}_#{field}")
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def text(obj, field="", options={})
|
|
@@ -49,8 +49,9 @@ module Sinatra
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def radio(obj, field, value, options={})
|
|
52
|
-
content = @params[obj] && @params[obj][field.to_s] == value ? "true" : ""
|
|
53
|
-
|
|
52
|
+
#content = @params[obj] && @params[obj][field.to_s] == value ? "true" : ""
|
|
53
|
+
# , :checked => content
|
|
54
|
+
tag :input, "", options.merge(:type => "radio", :id => "#{obj}_#{field}_#{value}", :name => "#{obj}[#{field}]", :value => value)
|
|
54
55
|
|
|
55
56
|
end
|
|
56
57
|
|
data/sinatra-formhelpers.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{sinatra-formhelpers}
|
|
5
|
-
s.version = "0.3.
|
|
5
|
+
s.version = "0.3.4"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["twilson63"]
|
|
9
|
-
s.date = %q{2009-
|
|
9
|
+
s.date = %q{2009-07-14}
|
|
10
10
|
s.email = %q{tom@jackrussellsoftware.com}
|
|
11
11
|
s.extra_rdoc_files = [
|
|
12
12
|
"LICENSE",
|
|
@@ -29,12 +29,12 @@ Gem::Specification.new do |s|
|
|
|
29
29
|
s.homepage = %q{http://github.com/twilson63/sinatra-formhelpers}
|
|
30
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
31
31
|
s.require_paths = ["lib"]
|
|
32
|
-
s.rubygems_version = %q{1.3.
|
|
32
|
+
s.rubygems_version = %q{1.3.3}
|
|
33
33
|
s.summary = %q{use basic form helpers for generic form management}
|
|
34
34
|
s.test_files = [
|
|
35
|
-
"test/
|
|
36
|
-
"test/
|
|
37
|
-
"test/
|
|
35
|
+
"test/contest.rb",
|
|
36
|
+
"test/formhelpers_test.rb",
|
|
37
|
+
"test/helper.rb"
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
if s.respond_to? :specification_version then
|
data/test/formhelpers_test.rb
CHANGED
|
@@ -38,6 +38,23 @@ class FormHelpersTest < Test::Unit::TestCase
|
|
|
38
38
|
it 'renders an label tag' do
|
|
39
39
|
get '/'
|
|
40
40
|
assert_equal "<label for='person_first_name'>First Name</label>\n", body
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'formhelpers custom display label' do
|
|
46
|
+
setup do
|
|
47
|
+
mock_app {
|
|
48
|
+
helpers Sinatra::FormHelpers
|
|
49
|
+
get '/' do
|
|
50
|
+
haml "= label :person, :first_name, 'Hello World'"
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'renders an label tag with display text' do
|
|
56
|
+
get '/'
|
|
57
|
+
assert_equal "<label for='person_first_name'>Hello World</label>\n", body
|
|
41
58
|
end
|
|
42
59
|
end
|
|
43
60
|
|
|
@@ -53,6 +70,7 @@ class FormHelpersTest < Test::Unit::TestCase
|
|
|
53
70
|
|
|
54
71
|
it 'renders an input tag type text without @params' do
|
|
55
72
|
get '/'
|
|
73
|
+
assert_contains "name='person[first_name]'"
|
|
56
74
|
assert_equal "<input name='person[first_name]' id='person_first_name' value='' type='text' />\n", body
|
|
57
75
|
end
|
|
58
76
|
end
|
|
@@ -184,7 +202,9 @@ class FormHelpersTest < Test::Unit::TestCase
|
|
|
184
202
|
|
|
185
203
|
it 'renders an input tag with a checkbox type' do
|
|
186
204
|
get '/'
|
|
187
|
-
|
|
205
|
+
assert_match /name=\'person\[active\]\'/, body
|
|
206
|
+
assert_match /id=\'person_active\'/, body
|
|
207
|
+
assert_match /type=\'checkbox\'/, body
|
|
188
208
|
end
|
|
189
209
|
end
|
|
190
210
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twilson63-sinatra-formhelpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- twilson63
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-07-14 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -81,6 +81,6 @@ signing_key:
|
|
|
81
81
|
specification_version: 3
|
|
82
82
|
summary: use basic form helpers for generic form management
|
|
83
83
|
test_files:
|
|
84
|
-
- test/helper.rb
|
|
85
84
|
- test/contest.rb
|
|
86
85
|
- test/formhelpers_test.rb
|
|
86
|
+
- test/helper.rb
|