Class: TestMarkup
- Inherits:
-
Builder::Test
show all
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb
Constant Summary
Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS
Minitest::Assertions::E, Minitest::Assertions::UNDEFINED
Minitest::Runnable::SIGNALS
Instance Attribute Summary
#assertions, #failures, #time
Instance Method Summary
collapse
#assert_nothing_raised
#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler
#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?
#after_setup, #after_teardown, #before_setup, #before_teardown, #teardown
#class_name, #error?, #location, #passed?, #result_code, #skipped?
#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff
#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler
Instance Method Details
209
210
211
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 209
def _name
"bob"
end
|
20
21
22
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 20
def setup
@xml = Builder::XmlMarkup.new
end
|
#test_ambiguous_markup ⇒ Object
157
158
159
160
161
162
163
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 157
def test_ambiguous_markup
ex = assert_raise(ArgumentError) {
@xml.h1("data1") { b }
}
assert_match(/\btext\b/, ex.message)
assert_match(/\bblock\b/, ex.message)
end
|
#test_append_text ⇒ Object
152
153
154
155
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 152
def test_append_text
@xml.p { |x| x.br; x.text! "HI" }
assert_equal "<p><br/>HI</p>", @xml.target!
end
|
#test_attributes ⇒ Object
58
59
60
61
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 58
def test_attributes
@xml.ref(:id => 12)
assert_equal %{<ref id="12"/>}, @xml.target!
end
|
#test_attributes_escaping_can_be_turned_on ⇒ Object
88
89
90
91
92
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 88
def test_attributes_escaping_can_be_turned_on
@xml = Builder::XmlMarkup.new
@xml.ref(:id => "<H&R \"block\">")
assert_equal %{<ref id="<H&R "block">"/>}, @xml.target!
end
|
#test_attributes_with_newlines ⇒ Object
113
114
115
116
117
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 113
def test_attributes_with_newlines
@xml.abbr("W3C", :title=>"World\nWide\rWeb\r\nConsortium")
assert_equal %{<abbr title="World Wide Web Consortium">W3C</abbr>},
@xml.target!
end
|
#test_attributes_with_text ⇒ Object
108
109
110
111
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 108
def test_attributes_with_text
@xml.a("link", :href=>"http://onestepback.org")
assert_equal %{<a href="http://onestepback.org">link</a>}, @xml.target!
end
|
#test_capitalized_method ⇒ Object
165
166
167
168
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 165
def test_capitalized_method
@xml.P { |x| x.B("hi"); x.BR(); x.EM { x.text! "world" } }
assert_equal "<P><B>hi</B><BR/><EM>world</EM></P>", @xml.target!
end
|
#test_complex ⇒ Object
119
120
121
122
123
124
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 119
def test_complex
@xml.body(:bg=>"#ffffff") { |x|
x.title("T", :style=>"red")
}
assert_equal %{<body bg="#ffffff"><title style="red">T</title></body>}, @xml.target!
end
|
#test_create ⇒ Object
24
25
26
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 24
def test_create
assert_not_nil @xml
end
|
#test_empty_value ⇒ Object
38
39
40
41
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 38
def test_empty_value
@xml.value("")
assert_equal "<value></value>", @xml.target!
end
|
#test_escaping ⇒ Object
170
171
172
173
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 170
def test_escaping
@xml.div { |x| x.text! "<hi>"; x.em("H&R Block") }
assert_equal %{<div><hi><em>H&R Block</em></div>}, @xml.target!
end
|
#test_funky_symbol ⇒ Object
126
127
128
129
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 126
def test_funky_symbol
@xml.tag!("non-ruby-token", :id=>1) { |x| x.ok }
assert_equal %{<non-ruby-token id="1"><ok/></non-ruby-token>}, @xml.target!
end
|
#test_mixed_attribute_escaping_with_nested_builders ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 94
def test_mixed_attribute_escaping_with_nested_builders
x = Builder::XmlMarkup.new(:target=>@xml)
@xml.ref(:id=>:"H&R") {
x.element(:tag=>"Long&Short")
}
assert_equal "<ref id=\"H&R\"><element tag=\"Long&Short\"/></ref>",
@xml.target!
end
|
#test_mixed_quotes_for_attrs ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 69
def test_mixed_quotes_for_attrs
@xml = Builder::XmlMarkup.new(:quote => :single)
x = Builder::XmlMarkup.new(:target=>@xml, :quote => :double)
@xml.ref(:id => 12) do
x.link(:id => 13)
end
assert_equal %{<ref id='12'><link id="13"/></ref>}, @xml.target!
end
|
#test_multiple_attributes ⇒ Object
103
104
105
106
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 103
def test_multiple_attributes
@xml.ref(:id => 12, :name => "bill")
assert_match %r{^<ref( id="12"| name="bill"){2}/>$}, @xml.target!
end
|
#test_nested ⇒ Object
53
54
55
56
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 53
def test_nested
@xml.outer { |x| x.inner("x") }
assert_equal "<outer><inner>x</inner></outer>", @xml.target!
end
|
175
176
177
178
179
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 175
def test_nil
b = Builder::XmlMarkup.new
b.tag! "foo", nil
assert_equal %{<foo/>}, b.target!
end
|
#test_nil_value ⇒ Object
43
44
45
46
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 43
def test_nil_value
@xml.value(nil)
assert_equal "<value/>", @xml.target!
end
|
#test_nil_with_explicit_nil_handling ⇒ Object
187
188
189
190
191
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 187
def test_nil_with_explicit_nil_handling
b = Builder::XmlMarkup.new(:explicit_nil_handling => true)
b.tag! "foo", nil
assert_equal %{<foo nil="true"/>}, b.target!
end
|
#test_nil_without_explicit_nil_handling ⇒ Object
181
182
183
184
185
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 181
def test_nil_without_explicit_nil_handling
b = Builder::XmlMarkup.new(:explicit_nil_handling => false)
b.tag! "foo", nil
assert_equal %{<foo/>}, b.target!
end
|
#test_no_explicit_marker ⇒ Object
136
137
138
139
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 136
def test_no_explicit_marker
@xml.p { |x| x.b("HI") }
assert_equal "<p><b>HI</b></p>", @xml.target!
end
|
#test_no_value ⇒ Object
48
49
50
51
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 48
def test_no_value
@xml.value()
assert_equal "<value/>", @xml.target!
end
|
#test_non_escaping ⇒ Object
193
194
195
196
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 193
def test_non_escaping
@xml.div("ns:xml"=>:"&xml;") { |x| x << "<h&i>"; x.em("H&R Block") }
assert_equal %{<div ns:xml="&xml;"><h&i><em>H&R Block</em></div>}, @xml.target!
end
|
#test_reference_local_vars ⇒ Object
141
142
143
144
145
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 141
def test_reference_local_vars
n = 3
@xml.ol { |x| n.times { x.li(n) } }
assert_equal "<ol><li>3</li><li>3</li><li>3</li></ol>", @xml.target!
end
|
#test_reference_methods ⇒ Object
147
148
149
150
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 147
def test_reference_methods
@xml.title { |x| x.a { x.b(_name) } }
assert_equal "<title><a><b>bob</b></a></title>", @xml.target!
end
|
#test_return_value ⇒ Object
198
199
200
201
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 198
def test_return_value
str = @xml.x("men")
assert_equal @xml.target!, str
end
|
#test_simple ⇒ Object
28
29
30
31
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 28
def test_simple
@xml.simple
assert_equal "<simple/>", @xml.target!
end
|
#test_single_quotes_for_attrs ⇒ Object
63
64
65
66
67
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 63
def test_single_quotes_for_attrs
@xml = Builder::XmlMarkup.new(:quote => :single)
@xml.ref(:id => 12)
assert_equal %{<ref id='12'/>}, @xml.target!
end
|
#test_stacked_builders ⇒ Object
203
204
205
206
207
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 203
def test_stacked_builders
b = Builder::XmlMarkup.new( :target => @xml )
b.div { @xml.span { @xml.a("text", :href=>"ref") } }
assert_equal "<div><span><a href=\"ref\">text</a></span></div>", @xml.target!
end
|
#test_string_attributes_are_escaped_by_default ⇒ Object
78
79
80
81
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 78
def test_string_attributes_are_escaped_by_default
@xml.ref(:id => "H&R")
assert_equal %{<ref id="H&R"/>}, @xml.target!
end
|
#test_symbol_attributes_are_unescaped_by_default ⇒ Object
83
84
85
86
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 83
def test_symbol_attributes_are_unescaped_by_default
@xml.ref(:id => :"H&R")
assert_equal %{<ref id="H&R"/>}, @xml.target!
end
|
#test_tag_can_handle_private_method ⇒ Object
131
132
133
134
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 131
def test_tag_can_handle_private_method
@xml.tag!("loop", :id=>1) { |x| x.ok }
assert_equal %{<loop id="1"><ok/></loop>}, @xml.target!
end
|
#test_value ⇒ Object
33
34
35
36
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 33
def test_value
@xml.value("hi")
assert_equal "<value>hi</value>", @xml.target!
end
|