padrino-helpers 0.12.9 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/padrino-helpers.rb +2 -2
- data/lib/padrino-helpers/asset_tag_helpers.rb +18 -26
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +3 -56
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
- data/lib/padrino-helpers/form_helpers.rb +11 -227
- data/lib/padrino-helpers/form_helpers/options.rb +5 -7
- data/lib/padrino-helpers/output_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +1 -2
- data/lib/padrino-helpers/render_helpers.rb +2 -23
- data/lib/padrino-helpers/tag_helpers.rb +1 -14
- data/lib/padrino/rendering.rb +4 -56
- data/lib/padrino/rendering/erb_template.rb +0 -12
- data/lib/padrino/rendering/erubis_template.rb +1 -1
- data/padrino-helpers.gemspec +1 -1
- data/test/fixtures/markup_app/views/form_for.erb +0 -28
- data/test/fixtures/markup_app/views/form_for.haml +0 -22
- data/test/fixtures/markup_app/views/form_for.slim +0 -21
- data/test/fixtures/markup_app/views/form_tag.erb +0 -21
- data/test/fixtures/markup_app/views/form_tag.haml +0 -14
- data/test/fixtures/markup_app/views/form_tag.slim +0 -14
- data/test/helper.rb +17 -6
- data/test/test_asset_tag_helpers.rb +92 -110
- data/test/test_form_builder.rb +450 -691
- data/test/test_form_helpers.rb +457 -770
- data/test/test_format_helpers.rb +37 -17
- data/test/test_helpers.rb +0 -8
- data/test/test_output_helpers.rb +72 -72
- data/test/test_render_helpers.rb +100 -142
- data/test/test_rendering.rb +1 -58
- data/test/test_tag_helpers.rb +39 -41
- metadata +118 -34
- data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +0 -79
@@ -45,9 +45,7 @@ module Padrino
|
|
45
45
|
#
|
46
46
|
def option_is_selected?(value, caption, selected_values)
|
47
47
|
Array(selected_values).any? do |selected|
|
48
|
-
value ?
|
49
|
-
value.to_s == selected.to_s :
|
50
|
-
caption.to_s == selected.to_s
|
48
|
+
[value.to_s, caption.to_s].include?(selected.to_s)
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
@@ -57,9 +55,9 @@ module Padrino
|
|
57
55
|
def options_for_select(option_items, state = {})
|
58
56
|
return [] if option_items.blank?
|
59
57
|
option_items.map do |caption, value, attributes|
|
60
|
-
html_attributes = { :value => value
|
61
|
-
html_attributes[:selected] ||= option_is_selected?(
|
62
|
-
html_attributes[:disabled] ||= option_is_selected?(
|
58
|
+
html_attributes = { :value => value ||= caption }.merge(attributes||{})
|
59
|
+
html_attributes[:selected] ||= option_is_selected?(value, caption, state[:selected])
|
60
|
+
html_attributes[:disabled] ||= option_is_selected?(value, caption, state[:disabled])
|
63
61
|
content_tag(:option, caption, html_attributes)
|
64
62
|
end
|
65
63
|
end
|
@@ -92,7 +90,7 @@ module Padrino
|
|
92
90
|
collection.map{ |item| [ item.send(fields.first), item.send(fields.last) ] }
|
93
91
|
else
|
94
92
|
options.delete(:options) || []
|
95
|
-
end
|
93
|
+
end
|
96
94
|
end
|
97
95
|
end
|
98
96
|
end
|
@@ -8,8 +8,7 @@ module Padrino
|
|
8
8
|
##
|
9
9
|
# Outputs the given text to the templates buffer directly.
|
10
10
|
#
|
11
|
-
def concat_to_template(text=""
|
12
|
-
return text if context && context.eval("@__in_ruby_literal")
|
11
|
+
def concat_to_template(text="")
|
13
12
|
output_buffer << text
|
14
13
|
nil
|
15
14
|
end
|
@@ -34,8 +34,8 @@ module Padrino
|
|
34
34
|
options = { :locals => {}, :layout => false }.update(options)
|
35
35
|
explicit_engine = options.delete(:engine)
|
36
36
|
|
37
|
-
path,
|
38
|
-
template_path = path
|
37
|
+
path,_,name = template.to_s.rpartition(File::SEPARATOR)
|
38
|
+
template_path = File.join(path,"_#{name}").to_sym
|
39
39
|
item_name = name.partition('.').first.to_sym
|
40
40
|
|
41
41
|
items, counter = if options[:collection].respond_to?(:inject)
|
@@ -58,27 +58,6 @@ module Padrino
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
alias :render_partial :partial
|
61
|
-
|
62
|
-
def self.included(base)
|
63
|
-
unless base.instance_methods.include?(:render) || base.private_instance_methods.include?(:render)
|
64
|
-
base.class_eval do
|
65
|
-
fail "gem 'tilt' is required" unless defined?(::Tilt)
|
66
|
-
|
67
|
-
def render(engine, file=nil, options={}, locals=nil, &block)
|
68
|
-
locals ||= options[:locals] || {}
|
69
|
-
engine, file = file, engine if file.nil?
|
70
|
-
template_engine = engine ? ::Tilt[engine] : ::Tilt.default_mapping[file]
|
71
|
-
fail "Engine #{engine.inspect} is not registered with Tilt" unless template_engine
|
72
|
-
unless File.file?(file.to_s)
|
73
|
-
engine_extensions = ::Tilt.default_mapping.extensions_for(template_engine)
|
74
|
-
file = Dir.glob("#{file}.{#{engine_extensions.join(',')}}").first || fail("Template '#{file}' not found")
|
75
|
-
end
|
76
|
-
template = template_engine.new(file.to_s, options)
|
77
|
-
template.render(options[:scope] || self, locals, &block)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
61
|
end
|
83
62
|
end
|
84
63
|
end
|
@@ -197,7 +197,7 @@ module Padrino
|
|
197
197
|
# # => <input type="text" name="username" required autofocus />
|
198
198
|
#
|
199
199
|
# input_tag :number, :name => 'credit_card', :autocomplete => :off
|
200
|
-
# # => <input type="number" autocomplete="off" />
|
200
|
+
# # => <input type="number" name="credit_card" autocomplete="off" />
|
201
201
|
#
|
202
202
|
def input_tag(type, options = {})
|
203
203
|
tag(:input, { :type => type }.update(options))
|
@@ -235,19 +235,6 @@ module Padrino
|
|
235
235
|
"<#{name}#{attributes}#{open ? '>' : ' />'}".html_safe
|
236
236
|
end
|
237
237
|
|
238
|
-
##
|
239
|
-
# Returns an escaped document link.
|
240
|
-
#
|
241
|
-
# @example
|
242
|
-
# escape_link('http://example.com/spaced link')
|
243
|
-
# # => 'http://example.com/spaced%20link'
|
244
|
-
# escape_link('already%20partially escaped')
|
245
|
-
# # => 'already%20partially%20escaped'
|
246
|
-
#
|
247
|
-
def escape_link(link)
|
248
|
-
link.gsub(' ', '%20')
|
249
|
-
end
|
250
|
-
|
251
238
|
private
|
252
239
|
|
253
240
|
##
|
data/lib/padrino/rendering.rb
CHANGED
@@ -34,11 +34,6 @@ module Padrino
|
|
34
34
|
/~$/ # This is for Gedit
|
35
35
|
] unless defined?(IGNORE_FILE_PATTERN)
|
36
36
|
|
37
|
-
##
|
38
|
-
# Defines common content-type alias mappings.
|
39
|
-
#
|
40
|
-
CONTENT_TYPE_ALIASES = { :htm => :html }
|
41
|
-
|
42
37
|
##
|
43
38
|
# Default options used in the resolve_template-method.
|
44
39
|
#
|
@@ -98,30 +93,6 @@ module Padrino
|
|
98
93
|
@layout = name
|
99
94
|
end
|
100
95
|
|
101
|
-
##
|
102
|
-
# Returns the cached template file to render for a given url,
|
103
|
-
# content_type and locale. Deprecated since 0.12.1
|
104
|
-
#
|
105
|
-
# @param [Array<template_path, content_type, locale>] render_options
|
106
|
-
#
|
107
|
-
def fetch_template_file(render_options)
|
108
|
-
logger.warn "##{__method__} is deprecated"
|
109
|
-
(@_cached_templates ||= {})[render_options]
|
110
|
-
end
|
111
|
-
|
112
|
-
##
|
113
|
-
# Caches the template file for the given rendering options. Deprecated since 0.12.1
|
114
|
-
#
|
115
|
-
# @param [String] template_file
|
116
|
-
# The path of the template file.
|
117
|
-
#
|
118
|
-
# @param [Array<template_path, content_type, locale>] render_options
|
119
|
-
#
|
120
|
-
def cache_template_file!(template_file, render_options)
|
121
|
-
logger.warn "##{__method__} is deprecated"
|
122
|
-
(@_cached_templates ||= {})[render_options] = template_file || []
|
123
|
-
end
|
124
|
-
|
125
96
|
##
|
126
97
|
# Returns the cached layout path.
|
127
98
|
#
|
@@ -226,7 +197,7 @@ module Padrino
|
|
226
197
|
# This means that no engine was explicitly defined
|
227
198
|
data, engine = resolve_template(engine, options) if data.nil?
|
228
199
|
|
229
|
-
ensure_rendering_engine(engine) || (options[:layout] ||=
|
200
|
+
ensure_rendering_engine(engine) || (options[:layout] ||= false)
|
230
201
|
|
231
202
|
# Cleanup the template.
|
232
203
|
@current_engine, engine_was = engine, @current_engine
|
@@ -239,20 +210,6 @@ module Padrino
|
|
239
210
|
@_out_buf = buf_was
|
240
211
|
end
|
241
212
|
|
242
|
-
##
|
243
|
-
# Returns the located layout tuple to be used for the rendered template
|
244
|
-
# (if available). Deprecated since 0.12.1
|
245
|
-
#
|
246
|
-
# @example
|
247
|
-
# resolve_layout
|
248
|
-
# # => ["/layouts/custom", :erb]
|
249
|
-
# # => [nil, nil]
|
250
|
-
#
|
251
|
-
def resolved_layout
|
252
|
-
logger.warn "##{__method__} is deprecated"
|
253
|
-
resolve_template(settings.fetch_layout_path, :raise_exceptions => false, :strict_format => true) || [nil, nil]
|
254
|
-
end
|
255
|
-
|
256
213
|
##
|
257
214
|
# Returns the template path and engine that match content_type (if present),
|
258
215
|
# I18n.locale.
|
@@ -350,14 +307,13 @@ module Padrino
|
|
350
307
|
end
|
351
308
|
|
352
309
|
def select_template(templates, template_path, content_type, _locale)
|
353
|
-
|
354
|
-
simple_content_type = [:html, :plain].include?(symbol)
|
310
|
+
simple_content_type = [:html, :plain].include?(content_type)
|
355
311
|
target_path, target_engine = path_and_engine(template_path)
|
356
312
|
|
357
|
-
templates.find{ |file,_| file.to_s == "#{target_path}.#{locale}.#{
|
313
|
+
templates.find{ |file,_| file.to_s == "#{target_path}.#{locale}.#{content_type}" } ||
|
358
314
|
templates.find{ |file,_| file.to_s == "#{target_path}.#{locale}" && simple_content_type } ||
|
359
315
|
templates.find{ |file,engine| engine == target_engine || File.extname(file.to_s) == ".#{target_engine}" } ||
|
360
|
-
templates.find{ |file,_| file.to_s == "#{target_path}.#{
|
316
|
+
templates.find{ |file,_| file.to_s == "#{target_path}.#{content_type}" } ||
|
361
317
|
templates.find{ |file,_| file.to_s == "#{target_path}" && simple_content_type }
|
362
318
|
end
|
363
319
|
|
@@ -379,14 +335,6 @@ module Padrino
|
|
379
335
|
require 'padrino/rendering/erb_template'
|
380
336
|
settings.set :erb, Padrino::Rendering.engine_configurations[:erb]
|
381
337
|
end
|
382
|
-
|
383
|
-
def content_type_symbol(type)
|
384
|
-
if defined?(::Rack::Mime::MIME_TYPES) && type.kind_of?(String) &&
|
385
|
-
::Rack::Mime::MIME_TYPES.key(type)
|
386
|
-
type = ::Rack::Mime::MIME_TYPES.key(type).sub(/\./,'').to_sym
|
387
|
-
end
|
388
|
-
CONTENT_TYPE_ALIASES[type] || type
|
389
|
-
end
|
390
338
|
end
|
391
339
|
end
|
392
340
|
end
|
@@ -1,18 +1,6 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Rendering
|
3
3
|
class SafeERB < ::ERB
|
4
|
-
class Compiler < ::ERB::Compiler
|
5
|
-
def add_insert_cmd(out, content)
|
6
|
-
out.push("@__in_ruby_literal = true")
|
7
|
-
super
|
8
|
-
out.push("@__in_ruby_literal = false")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def make_compiler(trim_mode)
|
13
|
-
Compiler.new(trim_mode)
|
14
|
-
end
|
15
|
-
|
16
4
|
def set_eoutvar(compiler, eoutvar = '_erbout')
|
17
5
|
compiler.put_cmd = "#{eoutvar}.safe_concat"
|
18
6
|
compiler.insert_cmd = "#{eoutvar}.concat"
|
@@ -7,7 +7,7 @@ module Padrino
|
|
7
7
|
# @api private
|
8
8
|
module SafeBufferEnhancer
|
9
9
|
def add_expr_literal(src, code)
|
10
|
-
src << "
|
10
|
+
src << " #{@bufvar}.concat((" << code << ').to_s);'
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_stmt(src, code)
|
data/padrino-helpers.gemspec
CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
25
25
|
|
26
26
|
s.add_dependency("padrino-support", Padrino.version)
|
27
|
-
s.add_dependency("tilt", "
|
27
|
+
s.add_dependency("tilt", "~> 1.4.1")
|
28
28
|
s.add_dependency("i18n", "~> 0.6", ">= 0.6.7")
|
29
29
|
end
|
@@ -50,34 +50,6 @@
|
|
50
50
|
<%= f.label :remember_me %>
|
51
51
|
<%= f.check_box :remember_me, :value => '1' %>
|
52
52
|
</p>
|
53
|
-
<p>
|
54
|
-
<%= f.label :datetime %>
|
55
|
-
<%= f.datetime_field :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0) %>
|
56
|
-
</p>
|
57
|
-
<p>
|
58
|
-
<%= f.label :datetime_local %>
|
59
|
-
<%= f.datetime_local_field :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0) %>
|
60
|
-
</p>
|
61
|
-
<p>
|
62
|
-
<%= f.label :date %>
|
63
|
-
<%= f.date_field :date, :max => DateTime.new(2000, 4, 1) %>
|
64
|
-
</p>
|
65
|
-
<p>
|
66
|
-
<%= f.label :month %>
|
67
|
-
<%= f.month_field :month, :max => DateTime.new(2000, 4, 1) %>
|
68
|
-
</p>
|
69
|
-
<p>
|
70
|
-
<%= f.label :week %>
|
71
|
-
<%= f.week_field :week, :max => DateTime.new(2000, 4, 1) %>
|
72
|
-
</p>
|
73
|
-
<p>
|
74
|
-
<%= f.label :time %>
|
75
|
-
<%= f.time_field :time, :max => Time.new(2008, 6, 21, 13, 30, 0) %>
|
76
|
-
</p>
|
77
|
-
<p>
|
78
|
-
<%= f.label :color %>
|
79
|
-
<%= f.color_field :color, :value => "#f00" %>
|
80
|
-
</p>
|
81
53
|
<p><%= f.submit "Create", :class => 'success', :id => 'demo-button' %></p>
|
82
54
|
<p><%= f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button' %></p>
|
83
55
|
<% end %>
|
@@ -38,28 +38,6 @@
|
|
38
38
|
%p
|
39
39
|
= f.label :remember_me
|
40
40
|
= f.check_box :remember_me, :value => "1"
|
41
|
-
%p
|
42
|
-
= f.label :datetime
|
43
|
-
= f.datetime_field :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0)
|
44
|
-
%p
|
45
|
-
= f.label :datetime_local
|
46
|
-
= f.datetime_local_field :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0)
|
47
|
-
%p
|
48
|
-
= f.label :date
|
49
|
-
= f.date_field :date, :max => DateTime.new(2000, 4, 1)
|
50
|
-
%p
|
51
|
-
= f.label :month
|
52
|
-
= f.month_field :month, :max => DateTime.new(2000, 4, 1)
|
53
|
-
%p
|
54
|
-
= f.label :week
|
55
|
-
= f.week_field :week, :max => DateTime.new(2000, 4, 1)
|
56
|
-
%p
|
57
|
-
= f.label :time
|
58
|
-
= f.time_field :time, :max => Time.new(2008, 6, 21, 13, 30, 0)
|
59
|
-
%p
|
60
|
-
= f.label :color
|
61
|
-
= f.color_field :color, :value => "#f00"
|
62
|
-
</p>
|
63
41
|
%p
|
64
42
|
= f.submit "Create", :class => 'success', :id => 'demo-button'
|
65
43
|
%p
|
@@ -38,27 +38,6 @@
|
|
38
38
|
p
|
39
39
|
= f.label :remember_me
|
40
40
|
= f.check_box :remember_me, :value => "1"
|
41
|
-
p
|
42
|
-
= f.label :datetime
|
43
|
-
= f.datetime_field :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0)
|
44
|
-
p
|
45
|
-
= f.label :datetime_local
|
46
|
-
= f.datetime_local_field :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0)
|
47
|
-
p
|
48
|
-
= f.label :date
|
49
|
-
= f.date_field :date, :max => DateTime.new(2000, 4, 1)
|
50
|
-
p
|
51
|
-
= f.label :month
|
52
|
-
= f.month_field :month, :max => DateTime.new(2000, 4, 1)
|
53
|
-
p
|
54
|
-
= f.label :week
|
55
|
-
= f.week_field :week, :max => DateTime.new(2000, 4, 1)
|
56
|
-
p
|
57
|
-
= f.label :time
|
58
|
-
= f.time_field :time, :max => Time.new(2008, 6, 21, 13, 30, 0)
|
59
|
-
p
|
60
|
-
= f.label :color
|
61
|
-
= f.color_field :color, :value => "#f00"
|
62
41
|
p
|
63
42
|
= f.submit "Create", :class => 'success', :id => 'demo-button'
|
64
43
|
p
|
@@ -83,27 +83,6 @@
|
|
83
83
|
<%= range_field_tag('ranger_with_min_max', :min => 1, :max => 50) %>
|
84
84
|
<%= range_field_tag('ranger_with_range', :range => 1..5) %>
|
85
85
|
</p>
|
86
|
-
<p>
|
87
|
-
<%= datetime_field_tag :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0) %>
|
88
|
-
</p>
|
89
|
-
<p>
|
90
|
-
<%= datetime_local_field_tag :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0) %>
|
91
|
-
</p>
|
92
|
-
<p>
|
93
|
-
<%= date_field_tag :date, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1) %>
|
94
|
-
</p>
|
95
|
-
<p>
|
96
|
-
<%= month_field_tag :month, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1) %>
|
97
|
-
</p>
|
98
|
-
<p>
|
99
|
-
<%= week_field_tag :week, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1) %>
|
100
|
-
</p>
|
101
|
-
<p>
|
102
|
-
<%= time_field_tag :time, :max => Time.new(2008, 6, 21, 13, 30, 0), :min => Time.new(1993, 2, 24, 1, 19, 12), :value => Time.new(2008, 6, 21, 13, 30, 0) %>
|
103
|
-
</p>
|
104
|
-
<p>
|
105
|
-
<%= color_field_tag :color, :value => "#f00" %>
|
106
|
-
</p>
|
107
86
|
<% end %>
|
108
87
|
<% field_set_tag(:class => 'buttons') do %>
|
109
88
|
<%= submit_tag "Login" %>
|
@@ -69,20 +69,6 @@
|
|
69
69
|
%p
|
70
70
|
= range_field_tag('ranger_with_min_max', :min => 1, :max => 50)
|
71
71
|
= range_field_tag('ranger_with_range', :range => 1..5)
|
72
|
-
%p
|
73
|
-
= datetime_field_tag :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0)
|
74
|
-
%p
|
75
|
-
= datetime_local_field_tag :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0)
|
76
|
-
%p
|
77
|
-
= date_field_tag :date, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
78
|
-
%p
|
79
|
-
= month_field_tag :month, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
80
|
-
%p
|
81
|
-
= week_field_tag :week, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
82
|
-
%p
|
83
|
-
= time_field_tag :time, :max => Time.new(2008, 6, 21, 13, 30, 0), :min => Time.new(1993, 2, 24, 1, 19, 12), :value => Time.new(2008, 6, 21, 13, 30, 0)
|
84
|
-
%p
|
85
|
-
= color_field_tag :color, :value => "#f00"
|
86
72
|
= field_set_tag(:class => 'buttons') do
|
87
73
|
= submit_tag "Login"
|
88
74
|
= button_tag "Cancel"
|
@@ -69,20 +69,6 @@
|
|
69
69
|
p
|
70
70
|
= range_field_tag('ranger_with_min_max', :min => 1, :max => 50)
|
71
71
|
= range_field_tag('ranger_with_range', :range => 1..5)
|
72
|
-
p
|
73
|
-
= datetime_field_tag :datetime, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0)
|
74
|
-
p
|
75
|
-
= datetime_local_field_tag :datetime_local, :max => DateTime.new(2000, 4, 1, 12, 0, 0), :min => DateTime.new(1993, 2, 24, 12, 30, 45), :value => DateTime.new(2000, 4, 1, 12, 0, 0)
|
76
|
-
p
|
77
|
-
= date_field_tag :date, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
78
|
-
p
|
79
|
-
= month_field_tag :month, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
80
|
-
p
|
81
|
-
= week_field_tag :week, :max => DateTime.new(2000, 4, 1), :min => DateTime.new(1993, 2, 24), :value => DateTime.new(2000, 4, 1)
|
82
|
-
p
|
83
|
-
= time_field_tag :time, :max => Time.new(2008, 6, 21, 13, 30, 0), :min => Time.new(1993, 2, 24, 1, 19, 12), :value => Time.new(2008, 6, 21, 13, 30, 0)
|
84
|
-
p
|
85
|
-
= color_field_tag :color, :value => "#f00"
|
86
72
|
|
87
73
|
= field_set_tag(:class => 'buttons') do
|
88
74
|
= submit_tag "Login"
|
data/test/helper.rb
CHANGED
@@ -4,22 +4,25 @@ require 'minitest/autorun'
|
|
4
4
|
require 'minitest/pride'
|
5
5
|
require 'mocha/setup'
|
6
6
|
require 'rack/test'
|
7
|
+
require 'webrat'
|
8
|
+
require 'active_support/time'
|
7
9
|
require 'builder'
|
8
10
|
require 'padrino-helpers'
|
9
|
-
require 'padrino/rendering'
|
10
|
-
require 'tilt/liquid'
|
11
|
-
require 'tilt/builder'
|
12
11
|
|
13
12
|
require 'ext/minitest-spec'
|
14
13
|
require 'ext/rack-test-methods'
|
15
|
-
require 'padrino/test-methods'
|
16
14
|
|
17
15
|
class MiniTest::Spec
|
18
16
|
include Padrino::Helpers::OutputHelpers
|
19
17
|
include Padrino::Helpers::TagHelpers
|
20
18
|
include Padrino::Helpers::AssetTagHelpers
|
21
19
|
include Rack::Test::Methods
|
22
|
-
include
|
20
|
+
include Webrat::Methods
|
21
|
+
include Webrat::Matchers
|
22
|
+
|
23
|
+
Webrat.configure do |config|
|
24
|
+
config.mode = :rack
|
25
|
+
end
|
23
26
|
|
24
27
|
def stop_time_for_test
|
25
28
|
time = Time.now
|
@@ -41,7 +44,7 @@ class MiniTest::Spec
|
|
41
44
|
path = "/views/#{name}"
|
42
45
|
path += ".#{options.delete(:locale)}" if options[:locale].present?
|
43
46
|
path += ".#{options[:format]}" if options[:format].present?
|
44
|
-
path += ".erb" unless options[:format].to_s =~ /erb|slim|haml|rss|atom|builder
|
47
|
+
path += ".erb" unless options[:format].to_s =~ /erb|slim|haml|rss|atom|builder/
|
45
48
|
path += ".builder" if options[:format].to_s =~ /rss|atom/
|
46
49
|
file = File.dirname(__FILE__) + path
|
47
50
|
File.open(file, 'w') { |io| io.write content }
|
@@ -75,3 +78,11 @@ class MiniTest::Spec
|
|
75
78
|
Rack::Lint.new(@app)
|
76
79
|
end
|
77
80
|
end
|
81
|
+
|
82
|
+
module Webrat
|
83
|
+
module Logging
|
84
|
+
def logger # @private
|
85
|
+
@logger = nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|