Class: TestIndentedXmlMarkup::TestXmlEvents

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

Defined Under Namespace

Classes: EventHandler

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

#pop_textObject



588
589
590
591
592
593
594
595
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 588

def pop_text
  result = ''.dup
  while ! @handler.events.empty? && @handler.events[0][0] == :text
	result << @handler.events[0][1]
	@handler.events.shift
  end
  result
end

#setupObject



550
551
552
553
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 550

def setup
  @handler = EventHandler.new
  @xe = Builder::XmlEvents.new(:target=>@handler)
end

#test_attributesObject



568
569
570
571
572
573
574
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 568

def test_attributes
  @xe.p("id"=>"2")
  ev = @handler.events.shift
  assert_equal [:start, :p], ev[0,2]
  assert_equal "2", ev[2]['id']
  assert_equal [:end, :p], @handler.events.shift
end

#test_indentedObject



576
577
578
579
580
581
582
583
584
585
586
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 576

def test_indented
  @xml = Builder::XmlEvents.new(:indent=>2, :target=>@handler)
  @xml.p { |x| x.b("HI") }
  assert_equal [:start, :p, nil], @handler.events.shift
  assert_equal "\n  ", pop_text
  assert_equal [:start, :b, nil], @handler.events.shift
  assert_equal "HI", pop_text
  assert_equal [:end, :b], @handler.events.shift
  assert_equal "\n", pop_text
  assert_equal [:end, :p], @handler.events.shift
end

#test_simpleObject



555
556
557
558
559
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 555

def test_simple
  @xe.p
  assert_equal [:start, :p, nil], @handler.events.shift
  assert_equal [:end, :p], @handler.events.shift
end

#test_textObject



561
562
563
564
565
566
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_markupbuilder.rb', line 561

def test_text
  @xe.p("HI")
  assert_equal [:start, :p, nil], @handler.events.shift
  assert_equal [:text, "HI"], @handler.events.shift
  assert_equal [:end, :p], @handler.events.shift
end