mini-max-gem 0.0.1

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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/mini-max-gem.gemspec +11 -0
  3. data/slim-5.2.1/CHANGES +496 -0
  4. data/slim-5.2.1/Gemfile +43 -0
  5. data/slim-5.2.1/LICENSE +21 -0
  6. data/slim-5.2.1/README.jp.md +1276 -0
  7. data/slim-5.2.1/README.md +1313 -0
  8. data/slim-5.2.1/Rakefile +80 -0
  9. data/slim-5.2.1/bin/slimrb +6 -0
  10. data/slim-5.2.1/doc/include.md +20 -0
  11. data/slim-5.2.1/doc/jp/include.md +20 -0
  12. data/slim-5.2.1/doc/jp/logic_less.md +137 -0
  13. data/slim-5.2.1/doc/jp/smart.md +102 -0
  14. data/slim-5.2.1/doc/jp/translator.md +28 -0
  15. data/slim-5.2.1/doc/logic_less.md +137 -0
  16. data/slim-5.2.1/doc/smart.md +120 -0
  17. data/slim-5.2.1/doc/translator.md +28 -0
  18. data/slim-5.2.1/lib/slim/code_attributes.rb +68 -0
  19. data/slim-5.2.1/lib/slim/command.rb +122 -0
  20. data/slim-5.2.1/lib/slim/controls.rb +61 -0
  21. data/slim-5.2.1/lib/slim/do_inserter.rb +34 -0
  22. data/slim-5.2.1/lib/slim/embedded.rb +248 -0
  23. data/slim-5.2.1/lib/slim/end_inserter.rb +63 -0
  24. data/slim-5.2.1/lib/slim/engine.rb +42 -0
  25. data/slim-5.2.1/lib/slim/erb_converter.rb +15 -0
  26. data/slim-5.2.1/lib/slim/filter.rb +31 -0
  27. data/slim-5.2.1/lib/slim/grammar.rb +24 -0
  28. data/slim-5.2.1/lib/slim/include.rb +58 -0
  29. data/slim-5.2.1/lib/slim/interpolation.rb +36 -0
  30. data/slim-5.2.1/lib/slim/logic_less/context.rb +126 -0
  31. data/slim-5.2.1/lib/slim/logic_less/filter.rb +81 -0
  32. data/slim-5.2.1/lib/slim/logic_less.rb +6 -0
  33. data/slim-5.2.1/lib/slim/parser.rb +535 -0
  34. data/slim-5.2.1/lib/slim/railtie.rb +19 -0
  35. data/slim-5.2.1/lib/slim/smart/escaper.rb +42 -0
  36. data/slim-5.2.1/lib/slim/smart/filter.rb +97 -0
  37. data/slim-5.2.1/lib/slim/smart/parser.rb +35 -0
  38. data/slim-5.2.1/lib/slim/smart.rb +9 -0
  39. data/slim-5.2.1/lib/slim/splat/builder.rb +115 -0
  40. data/slim-5.2.1/lib/slim/splat/filter.rb +93 -0
  41. data/slim-5.2.1/lib/slim/template.rb +6 -0
  42. data/slim-5.2.1/lib/slim/translator.rb +119 -0
  43. data/slim-5.2.1/lib/slim/version.rb +6 -0
  44. data/slim-5.2.1/lib/slim.rb +164 -0
  45. data/slim-5.2.1/slim.gemspec +33 -0
  46. data/slim-5.2.1/test/core/helper.rb +201 -0
  47. data/slim-5.2.1/test/core/test_code_blocks.rb +194 -0
  48. data/slim-5.2.1/test/core/test_code_escaping.rb +162 -0
  49. data/slim-5.2.1/test/core/test_code_evaluation.rb +181 -0
  50. data/slim-5.2.1/test/core/test_code_output.rb +168 -0
  51. data/slim-5.2.1/test/core/test_code_structure.rb +203 -0
  52. data/slim-5.2.1/test/core/test_commands.rb +219 -0
  53. data/slim-5.2.1/test/core/test_embedded_engines.rb +247 -0
  54. data/slim-5.2.1/test/core/test_encoding.rb +28 -0
  55. data/slim-5.2.1/test/core/test_erb_converter.rb +65 -0
  56. data/slim-5.2.1/test/core/test_html_attributes.rb +276 -0
  57. data/slim-5.2.1/test/core/test_html_escaping.rb +65 -0
  58. data/slim-5.2.1/test/core/test_html_structure.rb +599 -0
  59. data/slim-5.2.1/test/core/test_parser_errors.rb +148 -0
  60. data/slim-5.2.1/test/core/test_pretty.rb +163 -0
  61. data/slim-5.2.1/test/core/test_ruby_errors.rb +200 -0
  62. data/slim-5.2.1/test/core/test_slim_template.rb +78 -0
  63. data/slim-5.2.1/test/core/test_splat_prefix_option.rb +155 -0
  64. data/slim-5.2.1/test/core/test_tabs.rb +169 -0
  65. data/slim-5.2.1/test/core/test_text_interpolation.rb +79 -0
  66. data/slim-5.2.1/test/core/test_thread_options.rb +18 -0
  67. data/slim-5.2.1/test/core/test_unicode.rb +15 -0
  68. data/slim-5.2.1/test/include/files/recursive.slim +1 -0
  69. data/slim-5.2.1/test/include/files/slimfile.slim +3 -0
  70. data/slim-5.2.1/test/include/files/subdir/test.slim +1 -0
  71. data/slim-5.2.1/test/include/files/textfile +1 -0
  72. data/slim-5.2.1/test/include/test_include.rb +24 -0
  73. data/slim-5.2.1/test/literate/TESTS.md +1323 -0
  74. data/slim-5.2.1/test/literate/helper.rb +15 -0
  75. data/slim-5.2.1/test/literate/run.rb +92 -0
  76. data/slim-5.2.1/test/logic_less/test_logic_less.rb +330 -0
  77. data/slim-5.2.1/test/rails/Rakefile +7 -0
  78. data/slim-5.2.1/test/rails/app/assets/config/manifest.js +1 -0
  79. data/slim-5.2.1/test/rails/app/controllers/application_controller.rb +2 -0
  80. data/slim-5.2.1/test/rails/app/controllers/entries_controller.rb +5 -0
  81. data/slim-5.2.1/test/rails/app/controllers/slim_controller.rb +46 -0
  82. data/slim-5.2.1/test/rails/app/helpers/application_helper.rb +5 -0
  83. data/slim-5.2.1/test/rails/app/models/entry.rb +16 -0
  84. data/slim-5.2.1/test/rails/app/views/entries/edit.html.slim +3 -0
  85. data/slim-5.2.1/test/rails/app/views/layouts/application.html+testvariant.slim +10 -0
  86. data/slim-5.2.1/test/rails/app/views/layouts/application.html.slim +10 -0
  87. data/slim-5.2.1/test/rails/app/views/slim/_partial.html.slim +1 -0
  88. data/slim-5.2.1/test/rails/app/views/slim/attributes.html.slim +3 -0
  89. data/slim-5.2.1/test/rails/app/views/slim/content_for.html.slim +7 -0
  90. data/slim-5.2.1/test/rails/app/views/slim/erb.html.erb +1 -0
  91. data/slim-5.2.1/test/rails/app/views/slim/form_for.html.slim +2 -0
  92. data/slim-5.2.1/test/rails/app/views/slim/helper.html.slim +4 -0
  93. data/slim-5.2.1/test/rails/app/views/slim/integers.html.slim +1 -0
  94. data/slim-5.2.1/test/rails/app/views/slim/no_layout.html.slim +1 -0
  95. data/slim-5.2.1/test/rails/app/views/slim/normal.html.slim +1 -0
  96. data/slim-5.2.1/test/rails/app/views/slim/partial.html.slim +2 -0
  97. data/slim-5.2.1/test/rails/app/views/slim/splat.html.slim +2 -0
  98. data/slim-5.2.1/test/rails/app/views/slim/splat_with_delimiter.slim +1 -0
  99. data/slim-5.2.1/test/rails/app/views/slim/thread_options.html.slim +1 -0
  100. data/slim-5.2.1/test/rails/app/views/slim/variables.html.slim +1 -0
  101. data/slim-5.2.1/test/rails/app/views/slim/xml.slim +1 -0
  102. data/slim-5.2.1/test/rails/config/application.rb +44 -0
  103. data/slim-5.2.1/test/rails/config/boot.rb +10 -0
  104. data/slim-5.2.1/test/rails/config/environment.rb +5 -0
  105. data/slim-5.2.1/test/rails/config/environments/test.rb +34 -0
  106. data/slim-5.2.1/test/rails/config/initializers/backtrace_silencers.rb +7 -0
  107. data/slim-5.2.1/test/rails/config/initializers/inflections.rb +10 -0
  108. data/slim-5.2.1/test/rails/config/initializers/mime_types.rb +5 -0
  109. data/slim-5.2.1/test/rails/config/initializers/session_store.rb +8 -0
  110. data/slim-5.2.1/test/rails/config/locales/en.yml +5 -0
  111. data/slim-5.2.1/test/rails/config/routes.rb +60 -0
  112. data/slim-5.2.1/test/rails/config.ru +4 -0
  113. data/slim-5.2.1/test/rails/script/rails +6 -0
  114. data/slim-5.2.1/test/rails/test/helper.rb +34 -0
  115. data/slim-5.2.1/test/rails/test/test_slim.rb +102 -0
  116. data/slim-5.2.1/test/sinatra/contest.rb +91 -0
  117. data/slim-5.2.1/test/sinatra/helper.rb +143 -0
  118. data/slim-5.2.1/test/sinatra/test_core.rb +91 -0
  119. data/slim-5.2.1/test/sinatra/test_include.rb +16 -0
  120. data/slim-5.2.1/test/sinatra/views/embed_include_js.slim +8 -0
  121. data/slim-5.2.1/test/sinatra/views/embed_js.slim +11 -0
  122. data/slim-5.2.1/test/sinatra/views/footer.slim +1 -0
  123. data/slim-5.2.1/test/sinatra/views/hello.slim +1 -0
  124. data/slim-5.2.1/test/sinatra/views/layout2.slim +3 -0
  125. data/slim-5.2.1/test/smart/test_smart_text.rb +294 -0
  126. data/slim-5.2.1/test/translator/test_translator.rb +76 -0
  127. metadata +165 -0
@@ -0,0 +1,201 @@
1
+ begin
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ rescue LoadError
5
+ end
6
+
7
+ require 'minitest/autorun'
8
+ require 'slim'
9
+ require 'slim/grammar'
10
+
11
+ Slim::Engine.after Slim::Parser, Temple::Filters::Validator, grammar: Slim::Grammar
12
+ Slim::Engine.before :Pretty, Temple::Filters::Validator
13
+
14
+ class TestSlim < Minitest::Test
15
+ def setup
16
+ @env = Env.new
17
+ end
18
+
19
+ def render(source, options = {}, &block)
20
+ scope = options.delete(:scope)
21
+ locals = options.delete(:locals)
22
+ Slim::Template.new(options[:file], options) { source }.render(scope || @env, locals, &block)
23
+ end
24
+
25
+ class HtmlSafeString < String
26
+ def html_safe?
27
+ true
28
+ end
29
+
30
+ def to_s
31
+ self
32
+ end
33
+ end
34
+
35
+ def with_html_safe
36
+ String.send(:define_method, :html_safe?) { false }
37
+ String.send(:define_method, :html_safe) { HtmlSafeString.new(self) }
38
+ yield
39
+ ensure
40
+ String.send(:undef_method, :html_safe?) if String.method_defined?(:html_safe?)
41
+ String.send(:undef_method, :html_safe) if String.method_defined?(:html_safe)
42
+ end
43
+
44
+ def assert_html(expected, source, options = {}, &block)
45
+ assert_equal expected, render(source, options, &block)
46
+ end
47
+
48
+ def assert_syntax_error(message, source, options = {})
49
+ render(source, options)
50
+ raise 'Syntax error expected'
51
+ rescue Slim::Parser::SyntaxError => ex
52
+ assert_equal message, ex.message
53
+ message =~ /([^\s]+), Line (\d+)/
54
+ assert_backtrace ex, "#{$1}:#{$2}"
55
+ end
56
+
57
+ def assert_ruby_error(error, from, source, options = {})
58
+ render(source, options)
59
+ raise 'Ruby error expected'
60
+ rescue error => ex
61
+ assert_backtrace(ex, from)
62
+ end
63
+
64
+ def assert_backtrace(ex, from)
65
+ ex.backtrace[0] =~ /([^\s]+:\d+)/
66
+ assert_equal from, $1
67
+ end
68
+
69
+ def assert_ruby_syntax_error(from, source, options = {})
70
+ render(source, options)
71
+ raise 'Ruby syntax error expected'
72
+ rescue SyntaxError => ex
73
+ ex.message =~ /([^\s]+:\d+):/
74
+ assert_equal from, $1
75
+ end
76
+
77
+ def assert_runtime_error(message, source, options = {})
78
+ render(source, options)
79
+ raise Exception, 'Runtime error expected'
80
+ rescue RuntimeError => ex
81
+ assert_equal message, ex.message
82
+ end
83
+ end
84
+
85
+ class Env
86
+ attr_reader :var, :x
87
+
88
+ def initialize
89
+ @var = 'instance'
90
+ @x = 0
91
+ end
92
+
93
+ def id_helper
94
+ "notice"
95
+ end
96
+
97
+ def hash
98
+ {a: 'The letter a', b: 'The letter b'}
99
+ end
100
+
101
+ def show_first?(show = false)
102
+ show
103
+ end
104
+
105
+ def define_macro(name, &block)
106
+ @macro ||= {}
107
+ @macro[name.to_s] = block
108
+ ''
109
+ end
110
+
111
+ def call_macro(name, *args)
112
+ @macro[name.to_s].call(*args)
113
+ end
114
+
115
+ def hello_world(text = "Hello World from @env", opts = {})
116
+ text = text + (opts.to_a * " ") if opts.any?
117
+ if block_given?
118
+ "#{text} #{yield} #{text}"
119
+ else
120
+ text
121
+ end
122
+ end
123
+
124
+ def message(*args)
125
+ args.join(' ')
126
+ end
127
+
128
+ def action_path(*args)
129
+ "/action-#{args.join('-')}"
130
+ end
131
+
132
+ def in_keyword
133
+ "starts with keyword"
134
+ end
135
+
136
+ def evil_method
137
+ "<script>do_something_evil();</script>"
138
+ end
139
+
140
+ def output_number
141
+ 1337
142
+ end
143
+
144
+ def succ_x
145
+ @x = @x.succ
146
+ end
147
+
148
+ end
149
+
150
+ class ViewEnv
151
+ def output_number
152
+ 1337
153
+ end
154
+
155
+ def person
156
+ [{name: 'Joe'}, {name: 'Jack'}]
157
+ end
158
+
159
+ def people
160
+ %w(Andy Fred Daniel).collect{|n| Person.new(n)}
161
+ end
162
+
163
+ def cities
164
+ %w{Atlanta Melbourne Karlsruhe}
165
+ end
166
+
167
+ def people_with_locations
168
+ array = []
169
+ people.each_with_index do |p,i|
170
+ p.location = Location.new cities[i]
171
+ array << p
172
+ end
173
+ array
174
+ end
175
+ end
176
+
177
+ require 'forwardable'
178
+
179
+ class Person
180
+ extend Forwardable
181
+
182
+ attr_accessor :name
183
+
184
+ def initialize(name)
185
+ @name = name
186
+ end
187
+
188
+ def location=(location)
189
+ @location = location
190
+ end
191
+
192
+ def_delegators :@location, :city
193
+ end
194
+
195
+ class Location
196
+ attr_accessor :city
197
+
198
+ def initialize(city)
199
+ @city = city
200
+ end
201
+ end
@@ -0,0 +1,194 @@
1
+ require 'helper'
2
+
3
+ class TestSlimCodeBlocks < TestSlim
4
+ def test_render_with_output_code_block
5
+ source = %q{
6
+ p
7
+ = hello_world "Hello Ruby!" do
8
+ | Hello from within a block!
9
+ }
10
+
11
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
12
+ end
13
+
14
+ def test_render_with_output_code_block_without_do
15
+ source = %q{
16
+ p
17
+ = hello_world "Hello Ruby!"
18
+ | Hello from within a block!
19
+ }
20
+
21
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
22
+ end
23
+
24
+ def test_render_variable_ending_with_do
25
+ source = %q{
26
+ - appelido=10
27
+ p= appelido
28
+ - appelido
29
+ }
30
+
31
+ assert_html '<p>10</p>', source
32
+ end
33
+
34
+
35
+ def test_render_with_output_code_within_block
36
+ source = %q{
37
+ p
38
+ = hello_world "Hello Ruby!" do
39
+ = hello_world "Hello from within a block!"
40
+ }
41
+
42
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
43
+ end
44
+
45
+ def test_render_with_output_code_within_block_without_do
46
+ source = %q{
47
+ p
48
+ = hello_world "Hello Ruby!"
49
+ = hello_world "Hello from within a block!"
50
+ }
51
+
52
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
53
+ end
54
+
55
+ def test_render_with_output_code_within_block_2
56
+ source = %q{
57
+ p
58
+ = hello_world "Hello Ruby!" do
59
+ = hello_world "Hello from within a block!" do
60
+ = hello_world "And another one!"
61
+ }
62
+
63
+ assert_html '<p>Hello Ruby! Hello from within a block! And another one! Hello from within a block! Hello Ruby!</p>', source
64
+ end
65
+
66
+ def test_render_with_output_code_within_block_2_without_do
67
+ source = %q{
68
+ p
69
+ = hello_world "Hello Ruby!"
70
+ = hello_world "Hello from within a block!"
71
+ = hello_world "And another one!"
72
+ }
73
+
74
+ assert_html '<p>Hello Ruby! Hello from within a block! And another one! Hello from within a block! Hello Ruby!</p>', source
75
+ end
76
+
77
+ def test_output_block_with_arguments
78
+ source = %q{
79
+ p
80
+ = define_macro :person do |first_name, last_name|
81
+ .first_name = first_name
82
+ .last_name = last_name
83
+ == call_macro :person, 'John', 'Doe'
84
+ == call_macro :person, 'Max', 'Mustermann'
85
+ }
86
+
87
+ assert_html '<p><div class="first_name">John</div><div class="last_name">Doe</div><div class="first_name">Max</div><div class="last_name">Mustermann</div></p>', source
88
+ end
89
+
90
+
91
+ def test_render_with_control_code_loop
92
+ source = %q{
93
+ p
94
+ - 3.times do
95
+ | Hey!
96
+ }
97
+
98
+ assert_html '<p>Hey!Hey!Hey!</p>', source
99
+ end
100
+
101
+ def test_render_with_control_code_loop_without_do
102
+ source = %q{
103
+ p
104
+ - 3.times
105
+ | Hey!
106
+ }
107
+
108
+ assert_html '<p>Hey!Hey!Hey!</p>', source
109
+ end
110
+
111
+ def test_captured_code_block_with_conditional
112
+ source = %q{
113
+ = hello_world "Hello Ruby!" do
114
+ - if true
115
+ | Hello from within a block!
116
+ }
117
+
118
+ assert_html 'Hello Ruby! Hello from within a block! Hello Ruby!', source
119
+ end
120
+
121
+ def test_captured_code_block_with_conditional_without_do
122
+ source = %q{
123
+ = hello_world "Hello Ruby!"
124
+ - if true
125
+ | Hello from within a block!
126
+ }
127
+
128
+ assert_html 'Hello Ruby! Hello from within a block! Hello Ruby!', source
129
+ end
130
+
131
+ def test_if_without_content
132
+ source = %q{
133
+ - if true
134
+ }
135
+ assert_html '', source
136
+ end
137
+
138
+ def test_unless_without_content
139
+ source = %q{
140
+ - unless true
141
+ }
142
+ assert_html '', source
143
+ end
144
+
145
+ def test_if_with_comment
146
+ source = %q{
147
+ - if true
148
+ / comment
149
+ }
150
+ assert_html '', source
151
+ end
152
+
153
+ def test_control_do_with_comment
154
+ source = %q{
155
+ - hello_world "Hello"
156
+ / comment
157
+ }
158
+ assert_html '', source
159
+ end
160
+
161
+ def test_output_do_with_comment
162
+ source = %q{
163
+ = hello_world "Hello"
164
+ / comment
165
+ }
166
+ assert_html 'Hello', source
167
+ end
168
+
169
+ def test_output_if_without_content
170
+ source = %q{
171
+ = if true
172
+ }
173
+ assert_html '', source
174
+ end
175
+
176
+ def test_output_if_with_comment
177
+ source = %q{
178
+ = if true
179
+ / comment
180
+ }
181
+ assert_html '', source
182
+ end
183
+
184
+ def test_output_format_with_if
185
+ source = %q{
186
+ h3.subtitle
187
+ - if true
188
+ a href="#" Title true
189
+ - else
190
+ a href="#" Title false
191
+ }
192
+ assert_html '<h3 class="subtitle"><a href="#">Title true</a></h3>', source
193
+ end
194
+ end
@@ -0,0 +1,162 @@
1
+ require 'helper'
2
+
3
+ class TestSlimCodeEscaping < TestSlim
4
+ def test_escaping_evil_method
5
+ source = %q{
6
+ p = evil_method
7
+ }
8
+
9
+ assert_html '<p>&lt;script&gt;do_something_evil();&lt;/script&gt;</p>', source
10
+ end
11
+
12
+ def test_render_without_html_safe
13
+ source = %q{
14
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
15
+ }
16
+
17
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source
18
+ end
19
+
20
+ def test_render_without_html_safe2
21
+ source = %q{
22
+ p = "<strong>Hello World\\n, meet 'Slim'</strong>."
23
+ }
24
+
25
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet &#39;Slim&#39;&lt;/strong&gt;.</p>", source
26
+ end
27
+
28
+ def test_render_with_html_safe_false
29
+ source = %q{
30
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
31
+ }
32
+
33
+ with_html_safe do
34
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source, use_html_safe: true
35
+ end
36
+ end
37
+
38
+ def test_render_with_html_safe_true
39
+ source = %q{
40
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>.".html_safe
41
+ }
42
+
43
+ with_html_safe do
44
+ assert_html "<p><strong>Hello World\n, meet \"Slim\"</strong>.</p>", source, use_html_safe: true
45
+ end
46
+ end
47
+
48
+ def test_render_splat_with_html_safe_true
49
+ source = %q{
50
+ p *{ title: '&amp;'.html_safe }
51
+ }
52
+
53
+ with_html_safe do
54
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
55
+ end
56
+ end
57
+
58
+ def test_render_splat_with_html_safe_false
59
+ source = %q{
60
+ p *{ title: '&' }
61
+ }
62
+
63
+ with_html_safe do
64
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
65
+ end
66
+ end
67
+
68
+ def test_render_splat_injecting_evil_attr_name
69
+ source = %q{
70
+ p *{ "><script>alert(1)</script><p title" => 'test' }
71
+ }
72
+
73
+ with_html_safe do
74
+ assert_raises Slim::InvalidAttributeNameError do
75
+ render(source, use_html_safe: true)
76
+ end
77
+ end
78
+ end
79
+
80
+
81
+ def test_render_attribute_with_html_safe_true
82
+ source = %q{
83
+ p title=('&amp;'.html_safe)
84
+ }
85
+
86
+ with_html_safe do
87
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
88
+ end
89
+ end
90
+
91
+ def test_render_with_disable_escape_false
92
+ source = %q{
93
+ = "<p>Hello</p>"
94
+ == "<p>World</p>"
95
+ }
96
+
97
+ assert_html "&lt;p&gt;Hello&lt;/p&gt;<p>World</p>", source
98
+ end
99
+
100
+ def test_render_with_disable_escape_true
101
+ source = %q{
102
+ = "<p>Hello</p>"
103
+ == "<p>World</p>"
104
+ }
105
+
106
+ assert_html "<p>Hello</p><p>World</p>", source, disable_escape: true
107
+ end
108
+
109
+ def test_escaping_evil_method_with_pretty
110
+ source = %q{
111
+ p = evil_method
112
+ }
113
+
114
+ assert_html "<p>\n &lt;script&gt;do_something_evil();&lt;/script&gt;\n</p>", source, pretty: true
115
+ end
116
+
117
+ def test_render_without_html_safe_with_pretty
118
+ source = %q{
119
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
120
+ }
121
+
122
+ assert_html "<p>\n &lt;strong&gt;Hello World\n , meet \&quot;Slim\&quot;&lt;/strong&gt;.\n</p>", source, pretty: true
123
+ end
124
+
125
+ def test_render_with_html_safe_false_with_pretty
126
+ source = %q{
127
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
128
+ }
129
+
130
+ with_html_safe do
131
+ assert_html "<p>\n &lt;strong&gt;Hello World\n , meet \&quot;Slim\&quot;&lt;/strong&gt;.\n</p>", source, use_html_safe: true, pretty: true
132
+ end
133
+ end
134
+
135
+ def test_render_with_html_safe_true_with_pretty
136
+ source = %q{
137
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>.".html_safe
138
+ }
139
+
140
+ with_html_safe do
141
+ assert_html "<p>\n <strong>Hello World\n , meet \"Slim\"</strong>.\n</p>", source, use_html_safe: true, pretty: true
142
+ end
143
+ end
144
+
145
+ def test_render_with_disable_escape_false_with_pretty
146
+ source = %q{
147
+ = "<p>Hello</p>"
148
+ == "<p>World</p>"
149
+ }
150
+
151
+ assert_html "&lt;p&gt;Hello&lt;/p&gt;<p>World</p>", source, pretty: true
152
+ end
153
+
154
+ def test_render_with_disable_escape_true_with_pretty
155
+ source = %q{
156
+ = "<p>Hello</p>"
157
+ == "<p>World</p>"
158
+ }
159
+
160
+ assert_html "<p>Hello</p><p>World</p>", source, disable_escape: true, pretty: true
161
+ end
162
+ end