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

Constants inherited from Minitest::Test

Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS

Constants included from Minitest::Assertions

Minitest::Assertions::E, Minitest::Assertions::UNDEFINED

Constants inherited from Minitest::Runnable

Minitest::Runnable::SIGNALS

Instance Attribute Summary

Attributes inherited from Minitest::Runnable

#assertions, #failures, #time

Instance Method Summary collapse

Methods inherited from Builder::Test

#assert_nothing_raised

Methods inherited from Minitest::Test

#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

Methods included from Minitest::Guard

#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?

Methods included from Minitest::Test::LifecycleHooks

#after_setup, #after_teardown, #before_setup, #before_teardown, #teardown

Methods included from Minitest::Reportable

#class_name, #error?, #location, #passed?, #result_code, #skipped?

Methods included from Minitest::Assertions

#_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

Methods inherited from Minitest::Runnable

#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

Constructor Details

This class inherits a constructor from Minitest::Runnable

Instance Method Details

#_nameObject



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

#setupObject



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_markupObject



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_textObject



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_attributesObject



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_onObject



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="&lt;H&amp;R &quot;block&quot;&gt;"/>}, @xml.target!
end

#test_attributes_with_newlinesObject



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&#10;Wide&#13;Web&#13;&#10;Consortium">W3C</abbr>},
    @xml.target!
end

#test_attributes_with_textObject



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_methodObject



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_complexObject



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_createObject



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_valueObject



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_escapingObject



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>&lt;hi&gt;<em>H&amp;R Block</em></div>}, @xml.target!
end

#test_funky_symbolObject



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_buildersObject



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&amp;R") {
    x.element(:tag=>"Long&Short")
  }
  assert_equal "<ref id=\"H&amp;R\"><element tag=\"Long&amp;Short\"/></ref>",
    @xml.target!
end

#test_mixed_quotes_for_attrsObject



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_attributesObject



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_nestedObject



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

#test_nilObject



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_valueObject



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_handlingObject



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_handlingObject



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_markerObject



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_valueObject



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_escapingObject



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&amp;R Block</em></div>}, @xml.target!
end

#test_reference_local_varsObject



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_methodsObject



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_valueObject



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_simpleObject



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_attrsObject



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_buildersObject



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_defaultObject



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&amp;R"/>}, @xml.target!
end

#test_symbol_attributes_are_unescaped_by_defaultObject



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&amp;R")
  assert_equal %{<ref id="H&amp;R"/>}, @xml.target!
end

#test_tag_can_handle_private_methodObject



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_valueObject



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