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.
- checksums.yaml +13 -5
- data/Rakefile +1 -5
- data/lib/padrino-helpers.rb +2 -1
- data/lib/padrino-helpers/asset_tag_helpers.rb +16 -4
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +39 -1
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
- data/lib/padrino-helpers/form_helpers.rb +220 -1
- data/lib/padrino-helpers/form_helpers/options.rb +7 -5
- 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 +2 -1
- data/lib/padrino-helpers/render_helpers.rb +23 -2
- data/lib/padrino-helpers/tag_helpers.rb +13 -0
- data/lib/padrino/rendering.rb +2 -1
- data/lib/padrino/rendering/erb_template.rb +12 -0
- data/lib/padrino/rendering/erubis_template.rb +1 -1
- data/padrino-helpers.gemspec +1 -1
- data/test/fixtures/markup_app/views/form_for.erb +28 -0
- data/test/fixtures/markup_app/views/form_for.haml +22 -0
- data/test/fixtures/markup_app/views/form_for.slim +21 -0
- data/test/fixtures/markup_app/views/form_tag.erb +21 -0
- data/test/fixtures/markup_app/views/form_tag.haml +14 -0
- data/test/fixtures/markup_app/views/form_tag.slim +14 -0
- data/test/helper.rb +14 -68
- data/test/test_asset_tag_helpers.rb +106 -93
- data/test/test_form_builder.rb +691 -450
- data/test/test_form_helpers.rb +770 -457
- data/test/test_format_helpers.rb +17 -37
- data/test/test_helpers.rb +8 -0
- data/test/test_output_helpers.rb +72 -72
- data/test/test_render_helpers.rb +142 -100
- data/test/test_rendering.rb +30 -6
- data/test/test_tag_helpers.rb +41 -39
- metadata +37 -23
@@ -8,7 +8,8 @@ module Padrino
|
|
8
8
|
##
|
9
9
|
# Outputs the given text to the templates buffer directly.
|
10
10
|
#
|
11
|
-
def concat_to_template(text="")
|
11
|
+
def concat_to_template(text="", context=nil)
|
12
|
+
return text if context && context.eval("@__in_ruby_literal")
|
12
13
|
output_buffer << text
|
13
14
|
nil
|
14
15
|
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,_,name = template.to_s.rpartition(File::SEPARATOR)
|
38
|
-
template_path =
|
37
|
+
path, _, name = template.to_s.rpartition(File::SEPARATOR)
|
38
|
+
template_path = path.empty? ? :"_#{name}" : :"#{path}#{File::SEPARATOR}_#{name}"
|
39
39
|
item_name = name.partition('.').first.to_sym
|
40
40
|
|
41
41
|
items, counter = if options[:collection].respond_to?(:inject)
|
@@ -58,6 +58,27 @@ 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
|
61
82
|
end
|
62
83
|
end
|
63
84
|
end
|
@@ -235,6 +235,19 @@ 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
|
+
|
238
251
|
private
|
239
252
|
|
240
253
|
##
|
data/lib/padrino/rendering.rb
CHANGED
@@ -381,7 +381,8 @@ module Padrino
|
|
381
381
|
end
|
382
382
|
|
383
383
|
def content_type_symbol(type)
|
384
|
-
if defined?(::Rack::Mime::MIME_TYPES) && type.kind_of?(String)
|
384
|
+
if defined?(::Rack::Mime::MIME_TYPES) && type.kind_of?(String) &&
|
385
|
+
::Rack::Mime::MIME_TYPES.key(type)
|
385
386
|
type = ::Rack::Mime::MIME_TYPES.key(type).sub(/\./,'').to_sym
|
386
387
|
end
|
387
388
|
CONTENT_TYPE_ALIASES[type] || type
|
@@ -1,6 +1,18 @@
|
|
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
|
+
|
4
16
|
def set_eoutvar(compiler, eoutvar = '_erbout')
|
5
17
|
compiler.put_cmd = "#{eoutvar}.safe_concat"
|
6
18
|
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 << " #{@bufvar}.concat((" << code << ').to_s);'
|
10
|
+
src << " @__in_ruby_literal = true; #{@bufvar}.concat((" << code << ').to_s); @__in_ruby_literal = false;'
|
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", "< 3")
|
28
28
|
s.add_dependency("i18n", "~> 0.6", ">= 0.6.7")
|
29
29
|
end
|
@@ -50,6 +50,34 @@
|
|
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>
|
53
81
|
<p><%= f.submit "Create", :class => 'success', :id => 'demo-button' %></p>
|
54
82
|
<p><%= f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button' %></p>
|
55
83
|
<% end %>
|
@@ -38,6 +38,28 @@
|
|
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>
|
41
63
|
%p
|
42
64
|
= f.submit "Create", :class => 'success', :id => 'demo-button'
|
43
65
|
%p
|
@@ -38,6 +38,27 @@
|
|
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"
|
41
62
|
p
|
42
63
|
= f.submit "Create", :class => 'success', :id => 'demo-button'
|
43
64
|
p
|
@@ -83,6 +83,27 @@
|
|
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>
|
86
107
|
<% end %>
|
87
108
|
<% field_set_tag(:class => 'buttons') do %>
|
88
109
|
<%= submit_tag "Login" %>
|
@@ -69,6 +69,20 @@
|
|
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"
|
72
86
|
= field_set_tag(:class => 'buttons') do
|
73
87
|
= submit_tag "Login"
|
74
88
|
= button_tag "Cancel"
|
@@ -69,6 +69,20 @@
|
|
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"
|
72
86
|
|
73
87
|
= field_set_tag(:class => 'buttons') do
|
74
88
|
= submit_tag "Login"
|
data/test/helper.rb
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
ENV['RACK_ENV'] = 'test'
|
2
2
|
|
3
|
-
require File.expand_path('../../../load_paths', __FILE__)
|
4
3
|
require 'minitest/autorun'
|
5
4
|
require 'minitest/pride'
|
6
5
|
require 'mocha/setup'
|
7
6
|
require 'rack/test'
|
8
|
-
require 'webrat'
|
9
|
-
require 'padrino-helpers'
|
10
|
-
require 'active_support/time'
|
11
7
|
require 'builder'
|
8
|
+
require 'padrino-helpers'
|
9
|
+
require 'padrino/rendering'
|
10
|
+
require 'tilt/liquid'
|
11
|
+
require 'tilt/builder'
|
12
|
+
|
13
|
+
require 'ext/minitest-spec'
|
14
|
+
require 'ext/rack-test-methods'
|
15
|
+
require 'padrino/test-methods'
|
12
16
|
|
13
17
|
class MiniTest::Spec
|
14
18
|
include Padrino::Helpers::OutputHelpers
|
15
19
|
include Padrino::Helpers::TagHelpers
|
16
20
|
include Padrino::Helpers::AssetTagHelpers
|
17
21
|
include Rack::Test::Methods
|
18
|
-
include
|
19
|
-
include Webrat::Matchers
|
20
|
-
|
21
|
-
Webrat.configure do |config|
|
22
|
-
config.mode = :rack
|
23
|
-
end
|
22
|
+
include Padrino::TestMethods
|
24
23
|
|
25
24
|
def stop_time_for_test
|
26
25
|
time = Time.now
|
@@ -28,32 +27,6 @@ class MiniTest::Spec
|
|
28
27
|
return time
|
29
28
|
end
|
30
29
|
|
31
|
-
# assert_has_tag(:h1, :content => "yellow") { "<h1>yellow</h1>" }
|
32
|
-
# In this case, block is the html to evaluate
|
33
|
-
def assert_has_tag(name, attributes = {})
|
34
|
-
html = yield if block_given?
|
35
|
-
assert html.html_safe?, 'html_safe? failed'
|
36
|
-
matcher = HaveSelector.new(name, attributes)
|
37
|
-
raise "Please specify a block!" if html.blank?
|
38
|
-
assert matcher.matches?(html), matcher.failure_message
|
39
|
-
end
|
40
|
-
|
41
|
-
# assert_has_no_tag, tag(:h1, :content => "yellow") { "<h1>green</h1>" }
|
42
|
-
# In this case, block is the html to evaluate
|
43
|
-
def assert_has_no_tag(name, attributes = {})
|
44
|
-
html = yield if block_given?
|
45
|
-
attributes.merge!(:count => 0)
|
46
|
-
matcher = HaveSelector.new(name, attributes)
|
47
|
-
raise "Please specify a block!" if html.blank?
|
48
|
-
assert matcher.matches?(html), matcher.failure_message
|
49
|
-
end
|
50
|
-
|
51
|
-
# Asserts that a file matches the pattern
|
52
|
-
def assert_match_in_file(pattern, file)
|
53
|
-
assert File.exist?(file), "File '#{file}' does not exist!"
|
54
|
-
assert_match pattern, File.read(file)
|
55
|
-
end
|
56
|
-
|
57
30
|
# mock_model("Business", :new_record? => true) => <Business>
|
58
31
|
def mock_model(klazz, options={})
|
59
32
|
options.reverse_merge!(:class => klazz, :new_record? => false, :id => 20, :errors => {})
|
@@ -82,50 +55,23 @@ class MiniTest::Spec
|
|
82
55
|
end
|
83
56
|
|
84
57
|
def with_template(name, content, options={})
|
85
|
-
# Build a temp layout
|
86
58
|
template = create_template(name, content, options)
|
87
59
|
yield
|
88
60
|
ensure
|
89
|
-
# Remove temp layout
|
90
61
|
File.unlink(template) rescue nil
|
91
62
|
remove_views
|
92
63
|
end
|
93
64
|
alias :with_view :with_template
|
94
65
|
alias :with_layout :with_template
|
95
66
|
|
96
|
-
def mock_app(base=Padrino::Application
|
97
|
-
|
98
|
-
|
67
|
+
def mock_app(base=Padrino::Application, &block)
|
68
|
+
@app = Sinatra.new base do
|
69
|
+
register Padrino::Helpers
|
70
|
+
instance_eval &block
|
71
|
+
end
|
99
72
|
end
|
100
73
|
|
101
74
|
def app
|
102
75
|
Rack::Lint.new(@app)
|
103
76
|
end
|
104
|
-
|
105
|
-
# Asserts that a file matches the pattern
|
106
|
-
def assert_match_in_file(pattern, file)
|
107
|
-
assert File.exist?(file), "File '#{file}' does not exist!"
|
108
|
-
assert_match pattern, File.read(file)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Delegate other missing methods to response.
|
112
|
-
def method_missing(name, *args, &block)
|
113
|
-
if response && response.respond_to?(name)
|
114
|
-
response.send(name, *args, &block)
|
115
|
-
else
|
116
|
-
super(name, *args, &block)
|
117
|
-
end
|
118
|
-
rescue Rack::Test::Error # no response yet
|
119
|
-
super(name, *args, &block)
|
120
|
-
end
|
121
|
-
|
122
|
-
alias :response :last_response
|
123
|
-
end
|
124
|
-
|
125
|
-
module Webrat
|
126
|
-
module Logging
|
127
|
-
def logger # @private
|
128
|
-
@logger = nil
|
129
|
-
end
|
130
|
-
end
|
131
77
|
end
|
@@ -14,94 +14,114 @@ describe "AssetTagHelpers" do
|
|
14
14
|
|
15
15
|
describe 'for #flash_tag method' do
|
16
16
|
it 'should display flash with no given attributes' do
|
17
|
-
|
17
|
+
assert_html_has_tag(flash_tag(:notice), 'div.notice', :content => "Demo notice")
|
18
18
|
end
|
19
19
|
it 'should display flash with given attributes' do
|
20
20
|
actual_html = flash_tag(:notice, :class => 'notice', :id => 'notice-area')
|
21
|
-
|
21
|
+
assert_html_has_tag(actual_html, 'div.notice#notice-area', :content => "Demo notice")
|
22
22
|
end
|
23
23
|
it 'should display multiple flash tags with given attributes' do
|
24
24
|
flash[:error] = 'wrong'
|
25
25
|
flash[:success] = 'okey'
|
26
26
|
actual_html = flash_tag(:success, :warning, :error, :id => 'area')
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
assert_html_has_tag(actual_html, 'div.success#area', :content => flash[:success])
|
28
|
+
assert_html_has_tag(actual_html, 'div.error#area', :content => flash[:error])
|
29
|
+
assert_html_has_no_tag(actual_html, 'div.warning')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'for #link_to method' do
|
34
34
|
it 'should display link element with no given attributes' do
|
35
|
-
|
35
|
+
assert_html_has_tag(link_to('Sign up', '/register'), 'a', :content => "Sign up", :href => '/register')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should display link element with given attributes' do
|
39
39
|
actual_html = link_to('Sign up', '/register', :class => 'first', :id => 'linky')
|
40
|
-
|
40
|
+
assert_html_has_tag(actual_html, 'a#linky.first', :content => "Sign up", :href => '/register')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should display link element with anchor attribute' do
|
44
44
|
actual_html = link_to("Anchor", "/anchor", :anchor => :foo)
|
45
|
-
|
45
|
+
assert_html_has_tag(actual_html, 'a', :content => "Anchor", :href => '/anchor#foo')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should display link element with void url and options' do
|
49
49
|
actual_link = link_to('Sign up', :class => "test")
|
50
|
-
|
50
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '#', :class => 'test')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should display link element with remote option' do
|
54
54
|
actual_link = link_to('Sign up', '/register', :remote => true)
|
55
|
-
|
55
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-remote' => 'true')
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should display link element with method option' do
|
59
59
|
actual_link = link_to('Sign up', '/register', :method => :delete)
|
60
|
-
|
60
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-method' => 'delete', :rel => 'nofollow')
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should display link element with confirm option' do
|
64
64
|
actual_link = link_to('Sign up', '/register', :confirm => "Are you sure?")
|
65
|
-
|
65
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-confirm' => 'Are you sure?')
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should display link element with ruby block' do
|
69
69
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "Sign up" }
|
70
|
-
|
70
|
+
assert_html_has_tag(actual_link, 'a#binky.first', :content => "Sign up", :href => '/register')
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should escape the link text' do
|
74
74
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "<&>" }
|
75
|
-
|
75
|
+
assert_html_has_tag(actual_link, 'a#binky.first', :href => '/register')
|
76
76
|
assert_match "<&>", actual_link
|
77
77
|
end
|
78
78
|
|
79
|
+
it 'should escape the link href' do
|
80
|
+
actual_link = link_to('Sign up', '/register new%20user')
|
81
|
+
assert_html_has_tag(actual_link, 'a', :href => '/register%20new%20user')
|
82
|
+
end
|
83
|
+
|
79
84
|
it 'should not escape image_tag' do
|
80
85
|
actual_link = link_to(image_tag("/my/fancy/image.png"), :class => 'first', :id => 'binky')
|
81
|
-
|
86
|
+
assert_html_has_tag(actual_link, 'img', :src => "/my/fancy/image.png")
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should render alt text by default' do
|
90
|
+
actual_tag = image_tag("/my/fancy/image.png")
|
91
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image.png", :alt => "Image")
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should render humanized alt text' do
|
95
|
+
actual_tag = image_tag("/my/fancy/image_white.png")
|
96
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image_white.png", :alt => "Image white")
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should remove hash value from src path' do
|
100
|
+
actual_tag = image_tag("/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png")
|
101
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png", :alt => "Sprite")
|
82
102
|
end
|
83
103
|
|
84
104
|
it 'should display link block element in haml' do
|
85
|
-
|
86
|
-
|
87
|
-
|
105
|
+
get "/haml/link_to"
|
106
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
107
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
88
108
|
end
|
89
109
|
|
90
110
|
it 'should display link block element in erb' do
|
91
|
-
|
92
|
-
|
93
|
-
|
111
|
+
get "/erb/link_to"
|
112
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
113
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
94
114
|
end
|
95
115
|
|
96
116
|
it 'should display link block element in slim' do
|
97
|
-
|
98
|
-
|
99
|
-
|
117
|
+
get "/slim/link_to"
|
118
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
119
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
100
120
|
end
|
101
121
|
|
102
122
|
it 'should not double-escape' do
|
103
123
|
actual_link = link_to('test escape', '?a=1&b=2')
|
104
|
-
|
124
|
+
assert_html_has_tag(actual_link, 'a', :href => '?a=1&b=2')
|
105
125
|
assert_match %r{&}, actual_link
|
106
126
|
refute_match %r{&amp;}, actual_link
|
107
127
|
end
|
@@ -115,17 +135,17 @@ describe "AssetTagHelpers" do
|
|
115
135
|
describe 'for #mail_to method' do
|
116
136
|
it 'should display link element for mail to no caption' do
|
117
137
|
actual_html = mail_to('test@demo.com')
|
118
|
-
|
138
|
+
assert_html_has_tag(actual_html, :a, :href => "mailto:test@demo.com", :content => 'test@demo.com')
|
119
139
|
end
|
120
140
|
|
121
141
|
it 'should display link element for mail to with caption' do
|
122
142
|
actual_html = mail_to('test@demo.com', "My Email", :class => 'demo')
|
123
|
-
|
143
|
+
assert_html_has_tag(actual_html, :a, :href => "mailto:test@demo.com", :content => 'My Email', :class => 'demo')
|
124
144
|
end
|
125
145
|
|
126
146
|
it 'should display link element for mail to with caption and mail options' do
|
127
147
|
actual_html = mail_to('test@demo.com', "My Email", :subject => 'demo test', :class => 'demo', :cc => 'foo@test.com')
|
128
|
-
|
148
|
+
assert_html_has_tag(actual_html, :a, :class => 'demo')
|
129
149
|
assert_match %r{mailto\:test\@demo.com\?}, actual_html
|
130
150
|
assert_match %r{cc=foo\@test\.com}, actual_html
|
131
151
|
assert_match %r{subject\=demo\%20test}, actual_html
|
@@ -138,97 +158,92 @@ describe "AssetTagHelpers" do
|
|
138
158
|
end
|
139
159
|
|
140
160
|
it 'should not double-escape ampersands in query' do
|
141
|
-
actual_html = mail_to('to@demo.com', "Email", :
|
142
|
-
|
161
|
+
actual_html = mail_to('to@demo.com', "Email", :bcc => 'bcc@test.com', :subject => 'Hi there')
|
162
|
+
assert_html_has_tag(actual_html, :a, :href => 'mailto:to@demo.com?bcc=bcc@test.com&subject=Hi%20there', :content => 'Email')
|
143
163
|
assert_match %r{&}, actual_html
|
144
164
|
refute_match %r{&amp;}, actual_html
|
145
165
|
end
|
146
166
|
|
147
167
|
it 'should display mail link element in haml' do
|
148
|
-
|
149
|
-
|
150
|
-
|
168
|
+
get "/haml/mail_to"
|
169
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
170
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
151
171
|
end
|
152
172
|
|
153
173
|
it 'should display mail link element in erb' do
|
154
|
-
|
155
|
-
|
156
|
-
|
174
|
+
get "/erb/mail_to"
|
175
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
176
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
157
177
|
end
|
158
178
|
|
159
179
|
it 'should display mail link element in slim' do
|
160
|
-
|
161
|
-
|
162
|
-
|
180
|
+
get "/slim/mail_to"
|
181
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
182
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
163
183
|
end
|
164
184
|
end
|
165
185
|
|
166
186
|
describe 'for #meta_tag method' do
|
167
187
|
it 'should display meta tag with given content and name' do
|
168
188
|
actual_html = meta_tag("weblog,news", :name => "keywords")
|
169
|
-
|
189
|
+
assert_html_has_tag(actual_html, "meta", :name => "keywords", :content => "weblog,news")
|
170
190
|
end
|
171
191
|
|
172
192
|
it 'should display meta tag with given content and http-equiv' do
|
173
193
|
actual_html = meta_tag("text/html; charset=UTF-8", :"http-equiv" => "Content-Type")
|
174
|
-
|
194
|
+
assert_html_has_tag(actual_html, "meta", :"http-equiv" => "Content-Type", :content => "text/html; charset=UTF-8")
|
175
195
|
end
|
176
196
|
|
177
197
|
it 'should display meta tag element in haml' do
|
178
|
-
|
179
|
-
|
180
|
-
|
198
|
+
get "/haml/meta_tag"
|
199
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
200
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
181
201
|
end
|
182
202
|
|
183
203
|
it 'should display meta tag element in erb' do
|
184
|
-
|
185
|
-
|
186
|
-
|
204
|
+
get "/erb/meta_tag"
|
205
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
206
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
187
207
|
end
|
188
208
|
|
189
209
|
it 'should display meta tag element in slim' do
|
190
|
-
|
191
|
-
|
192
|
-
|
210
|
+
get "/slim/meta_tag"
|
211
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
212
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
193
213
|
end
|
194
214
|
end
|
195
215
|
|
196
216
|
describe 'for #image_tag method' do
|
197
217
|
it 'should display image tag absolute link with no options' do
|
198
|
-
|
199
|
-
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
218
|
+
assert_html_has_tag(image_tag('/absolute/pic.gif'), 'img', :src => "/absolute/pic.gif")
|
200
219
|
end
|
201
220
|
|
202
221
|
it 'should display image tag relative link with specified uri root' do
|
203
222
|
time = stop_time_for_test
|
204
223
|
self.class.stubs(:uri_root).returns("/blog")
|
205
|
-
|
224
|
+
assert_html_has_tag(image_tag('relative/pic.gif'), 'img', :src => "/blog/images/relative/pic.gif?#{time.to_i}")
|
206
225
|
end
|
207
226
|
|
208
227
|
it 'should display image tag relative link with options' do
|
209
228
|
time = stop_time_for_test
|
210
|
-
|
211
|
-
image_tag('relative/pic.gif', :class => 'photo') }
|
229
|
+
assert_html_has_tag(image_tag('relative/pic.gif', :class => 'photo'), 'img.photo', :src => "/images/relative/pic.gif?#{time.to_i}")
|
212
230
|
end
|
213
231
|
|
214
232
|
it 'should display image tag uri link with options' do
|
215
|
-
|
216
|
-
assert_has_tag('img.photo', :src => "http://demo.org/pic.gif") { image_tag('http://demo.org/pic.gif', :class => 'photo') }
|
233
|
+
assert_html_has_tag(image_tag('http://demo.org/pic.gif', :class => 'photo'), 'img.photo', :src => "http://demo.org/pic.gif")
|
217
234
|
end
|
218
235
|
|
219
236
|
it 'should display image tag relative link with incorrect spacing' do
|
220
237
|
time = stop_time_for_test
|
221
|
-
|
222
|
-
image_tag(' relative/ pic.gif ', :class => 'photo')
|
223
|
-
}
|
238
|
+
assert_html_has_tag(image_tag(' relative/ pic.gif ', :class => 'photo'), 'img.photo', :src => "/images/%20relative/%20pic.gif%20%20?#{time.to_i}")
|
224
239
|
end
|
225
240
|
|
226
241
|
it 'should not use a timestamp if stamp setting is false' do
|
227
|
-
|
242
|
+
assert_html_has_tag(image_tag('/absolute/pic.gif'), 'img', :src => "/absolute/pic.gif")
|
228
243
|
end
|
229
244
|
|
230
245
|
it 'should have xhtml convention tag' do
|
231
|
-
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" />'
|
246
|
+
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" alt="Pic" />'
|
232
247
|
end
|
233
248
|
end
|
234
249
|
|
@@ -237,7 +252,7 @@ describe "AssetTagHelpers" do
|
|
237
252
|
time = stop_time_for_test
|
238
253
|
actual_html = stylesheet_link_tag('style')
|
239
254
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
240
|
-
|
255
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}"))
|
241
256
|
assert actual_html.html_safe?
|
242
257
|
end
|
243
258
|
|
@@ -245,14 +260,14 @@ describe "AssetTagHelpers" do
|
|
245
260
|
time = stop_time_for_test
|
246
261
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
247
262
|
actual_html = stylesheet_link_tag('example/demo/style')
|
248
|
-
|
263
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/stylesheets/example/demo/style.css?#{time.to_i}"))
|
249
264
|
end
|
250
265
|
|
251
266
|
it 'should display stylesheet link item with absolute path' do
|
252
267
|
time = stop_time_for_test
|
253
268
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
254
269
|
actual_html = stylesheet_link_tag('/css/style')
|
255
|
-
|
270
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/css/style.css"))
|
256
271
|
end
|
257
272
|
|
258
273
|
it 'should display stylesheet link item with uri root' do
|
@@ -260,27 +275,27 @@ describe "AssetTagHelpers" do
|
|
260
275
|
time = stop_time_for_test
|
261
276
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
262
277
|
actual_html = stylesheet_link_tag('style')
|
263
|
-
|
278
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/blog/stylesheets/style.css?#{time.to_i}"))
|
264
279
|
end
|
265
280
|
|
266
281
|
it 'should display stylesheet link items' do
|
267
282
|
time = stop_time_for_test
|
268
283
|
actual_html = stylesheet_link_tag('style', 'layout.css', 'http://google.com/style.css')
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
284
|
+
assert_html_has_tag(actual_html, 'link', :rel => "stylesheet", :type => "text/css", :count => 3)
|
285
|
+
assert_html_has_tag(actual_html, 'link', :href => "/stylesheets/style.css?#{time.to_i}")
|
286
|
+
assert_html_has_tag(actual_html, 'link', :href => "/stylesheets/layout.css?#{time.to_i}")
|
287
|
+
assert_html_has_tag(actual_html, 'link', :href => "http://google.com/style.css")
|
273
288
|
assert_equal actual_html, stylesheet_link_tag(['style', 'layout.css', 'http://google.com/style.css'])
|
274
289
|
end
|
275
290
|
|
276
291
|
it 'should not use a timestamp if stamp setting is false' do
|
277
292
|
self.class.expects(:asset_stamp).returns(false)
|
278
293
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
279
|
-
|
294
|
+
assert_html_has_tag(stylesheet_link_tag('style'), 'link', expected_options.merge(:href => "/stylesheets/style.css"))
|
280
295
|
end
|
281
296
|
|
282
297
|
it 'should display stylesheet link used custom options' do
|
283
|
-
|
298
|
+
assert_html_has_tag(stylesheet_link_tag('style', :media => 'screen'), 'link', :rel => 'stylesheet', :media => 'screen')
|
284
299
|
end
|
285
300
|
end
|
286
301
|
|
@@ -288,7 +303,7 @@ describe "AssetTagHelpers" do
|
|
288
303
|
it 'should display javascript item' do
|
289
304
|
time = stop_time_for_test
|
290
305
|
actual_html = javascript_include_tag('application')
|
291
|
-
|
306
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js?#{time.to_i}", :type => "text/javascript")
|
292
307
|
assert actual_html.html_safe?
|
293
308
|
end
|
294
309
|
|
@@ -297,60 +312,58 @@ describe "AssetTagHelpers" do
|
|
297
312
|
self.class.stubs(:js_asset_folder).returns('js')
|
298
313
|
assert_equal 'js', asset_folder_name(:js)
|
299
314
|
actual_html = javascript_include_tag('application')
|
300
|
-
|
315
|
+
assert_html_has_tag(actual_html, 'script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript")
|
301
316
|
end
|
302
317
|
|
303
318
|
it 'should display javascript item for long relative path' do
|
304
319
|
time = stop_time_for_test
|
305
320
|
actual_html = javascript_include_tag('example/demo/application')
|
306
|
-
|
321
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/example/demo/application.js?#{time.to_i}", :type => "text/javascript")
|
307
322
|
end
|
308
323
|
|
309
324
|
it 'should display javascript item for path containing js' do
|
310
325
|
time = stop_time_for_test
|
311
326
|
actual_html = javascript_include_tag 'test/jquery.json'
|
312
|
-
|
327
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/test/jquery.json?#{time.to_i}", :type => "text/javascript")
|
313
328
|
end
|
314
329
|
|
315
330
|
it 'should display javascript item for path containing period' do
|
316
331
|
time = stop_time_for_test
|
317
332
|
actual_html = javascript_include_tag 'test/jquery.min'
|
318
|
-
|
333
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/test/jquery.min.js?#{time.to_i}", :type => "text/javascript")
|
319
334
|
end
|
320
335
|
|
321
336
|
it 'should display javascript item with absolute path' do
|
322
|
-
time = stop_time_for_test
|
323
337
|
actual_html = javascript_include_tag('/js/application')
|
324
|
-
|
338
|
+
assert_html_has_tag(actual_html, 'script', :src => "/js/application.js", :type => "text/javascript")
|
325
339
|
end
|
326
340
|
|
327
341
|
it 'should display javascript item with uri root' do
|
328
342
|
self.class.stubs(:uri_root).returns("/blog")
|
329
343
|
time = stop_time_for_test
|
330
344
|
actual_html = javascript_include_tag('application')
|
331
|
-
|
345
|
+
assert_html_has_tag(actual_html, 'script', :src => "/blog/javascripts/application.js?#{time.to_i}", :type => "text/javascript")
|
332
346
|
end
|
333
347
|
|
334
348
|
it 'should not append extension to absolute paths' do
|
335
|
-
time = stop_time_for_test
|
336
349
|
actual_html = javascript_include_tag('https://maps.googleapis.com/maps/api/js?key=value&sensor=false')
|
337
|
-
|
350
|
+
assert_html_has_tag(actual_html, 'script', :src => "https://maps.googleapis.com/maps/api/js?key=value&sensor=false")
|
338
351
|
end
|
339
352
|
|
340
353
|
it 'should display javascript items' do
|
341
354
|
time = stop_time_for_test
|
342
355
|
actual_html = javascript_include_tag('application', 'base.js', 'http://google.com/lib.js')
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
356
|
+
assert_html_has_tag(actual_html, 'script', :type => "text/javascript", :count => 3)
|
357
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js?#{time.to_i}")
|
358
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/base.js?#{time.to_i}")
|
359
|
+
assert_html_has_tag(actual_html, 'script', :src => "http://google.com/lib.js")
|
347
360
|
assert_equal actual_html, javascript_include_tag(['application', 'base.js', 'http://google.com/lib.js'])
|
348
361
|
end
|
349
362
|
|
350
363
|
it 'should not use a timestamp if stamp setting is false' do
|
351
364
|
self.class.expects(:asset_stamp).returns(false)
|
352
365
|
actual_html = javascript_include_tag('application')
|
353
|
-
|
366
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js", :type => "text/javascript")
|
354
367
|
end
|
355
368
|
end
|
356
369
|
|
@@ -358,33 +371,33 @@ describe "AssetTagHelpers" do
|
|
358
371
|
it 'should display favicon' do
|
359
372
|
time = stop_time_for_test
|
360
373
|
actual_html = favicon_tag('icons/favicon.png')
|
361
|
-
|
374
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/png', :href => "/images/icons/favicon.png?#{time.to_i}")
|
362
375
|
end
|
363
376
|
|
364
377
|
it 'should match type with file ext' do
|
365
378
|
time = stop_time_for_test
|
366
379
|
actual_html = favicon_tag('favicon.ico')
|
367
|
-
|
380
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.ico?#{time.to_i}")
|
368
381
|
end
|
369
382
|
|
370
383
|
it 'should allow option overrides' do
|
371
384
|
time = stop_time_for_test
|
372
385
|
actual_html = favicon_tag('favicon.png', :type => 'image/ico')
|
373
|
-
|
386
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.png?#{time.to_i}")
|
374
387
|
end
|
375
388
|
end
|
376
389
|
|
377
390
|
describe 'for #feed_tag method' do
|
378
391
|
it 'should generate correctly link tag for rss' do
|
379
|
-
|
392
|
+
assert_html_has_tag(feed_tag(:rss, "/blog/post.rss"), 'link', :type => 'application/rss+xml', :rel => 'alternate', :href => "/blog/post.rss", :title => 'rss')
|
380
393
|
end
|
381
394
|
|
382
395
|
it 'should generate correctly link tag for atom' do
|
383
|
-
|
396
|
+
assert_html_has_tag(feed_tag(:atom, "/blog/post.atom"), 'link', :type => 'application/atom+xml', :rel => 'alternate', :href => "/blog/post.atom", :title => 'atom')
|
384
397
|
end
|
385
398
|
|
386
399
|
it 'should override options' do
|
387
|
-
|
400
|
+
assert_html_has_tag(feed_tag(:rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title"), 'link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title')
|
388
401
|
end
|
389
402
|
end
|
390
403
|
|