lib/test_xml/assertions.rb in test_xml-0.1.5 vs lib/test_xml/assertions.rb in test_xml-0.1.6

- old
+ new

@@ -39,6 +39,29 @@ :matcher => :equal_xml_structure, :message_for_should => lambda { |a,b| "the xml:\n#{a}\nshould exactly match xml structure:\n#{b}" }, :message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not exactly match xml structure:\n#{b} but it does" } ) ] + + module Assertions + ASSERTIONS.each do |cfg| + define_method(cfg.assert_name) do |a, b| + correct_assert(MatcherMethods.send(cfg.name, a, b), cfg.message_for_should.call(a, b)) + end + + define_method(cfg.assert_not_name) do |a, b| + correct_assert(! MatcherMethods.send(cfg.name, a, b), cfg.message_for_should_not.call(a, b)) + end + end + + private + def correct_assert(boolean, message) + if RUBY_VERSION =~ /1.9.2/ or defined?(MiniTest) + assert(boolean, message) + else + assert_block(message) do + boolean + end + end + end + end end \ No newline at end of file