diff --git a/test/html4/test_document.rb b/test/html4/test_document.rb index 357c4bcc7b4..0372db438ba 100644 --- a/test/html4/test_document.rb +++ b/test/html4/test_document.rb @@ -626,7 +626,7 @@ def html.path # issue #1821, #2110 def test_parse_can_take_pathnames - assert(File.size(HTML_FILE) > 4096) # file must be big enough to trip the read callback more than once + assert_operator(File.size(HTML_FILE), :>, 4096) # file must be big enough to trip the read callback more than once doc = Nokogiri::HTML4.parse(Pathname.new(HTML_FILE)) diff --git a/test/test_memory_leak.rb b/test/test_memory_leak.rb index 14d0889b254..d337645f3ed 100644 --- a/test/test_memory_leak.rb +++ b/test/test_memory_leak.rb @@ -84,7 +84,7 @@ def test_for_memory_leak end 2.times { GC.start } count_end = count_object_space_documents - assert((count_end - count_start) <= 2, "memory leak detected") + assert_operator((count_end - count_start), :<=, 2, "memory leak detected") rescue LoadError puts "\ndike is not installed, skipping memory leak test" end @@ -289,28 +289,28 @@ def test_object_space_memsize_of asdf XML - assert(more_children_size > base_size, "adding children should increase memsize") + assert_operator(more_children_size, :>, base_size, "adding children should increase memsize") attributes_size = ObjectSpace.memsize_of(Nokogiri::XML(<<~XML)) asdf XML - assert(attributes_size > base_size, "adding attributes should increase memsize") + assert_operator(attributes_size, :>, base_size, "adding attributes should increase memsize") string_size = ObjectSpace.memsize_of(Nokogiri::XML(<<~XML)) asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf XML - assert(string_size > base_size, "longer strings should increase memsize") + assert_operator(string_size, :>, base_size, "longer strings should increase memsize") bigger_name_size = ObjectSpace.memsize_of(Nokogiri::XML(<<~XML)) asdf XML - assert(bigger_name_size > base_size, "longer tags should increase memsize") + assert_operator(bigger_name_size, :>, base_size, "longer tags should increase memsize") end def test_object_space_memsize_with_dtd diff --git a/test/xml/sax/test_push_parser.rb b/test/xml/sax/test_push_parser.rb index 7c6e01e266d..5c9ddd38405 100644 --- a/test/xml/sax/test_push_parser.rb +++ b/test/xml/sax/test_push_parser.rb @@ -173,7 +173,7 @@ def error(msg)

XML parser.finish - assert(parser.document.errors.size >= 1) + assert_operator(parser.document.errors.size, :>=, 1) assert_equal [["p", []], ["bar", []]], parser.document.start_elements assert_equal "FooBar", parser.document.data.map { |x| x.gsub(/\s/, "") @@ -186,7 +186,7 @@ def error(msg) # This is ISO_8859-1: parser << "Gau\337" parser.finish - assert(parser.document.errors.size >= 1) + assert_operator(parser.document.errors.size, :>=, 1) assert_equal "Gau\337", parser.document.data.join assert_equal [["r"]], parser.document.end_elements end diff --git a/test/xml/test_document.rb b/test/xml/test_document.rb index e39dbab26c7..ad8575704df 100644 --- a/test/xml/test_document.rb +++ b/test/xml/test_document.rb @@ -685,7 +685,7 @@ def xml.path # issue #1821, #2110 def test_parse_can_take_pathnames - assert(File.size(XML_ATOM_FILE) > 4096) # file must be big enough to trip the read callback more than once + assert_operator(File.size(XML_ATOM_FILE), :>, 4096) # file must be big enough to trip the read callback more than once doc = Nokogiri::XML.parse(Pathname.new(XML_ATOM_FILE)) diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb index 5946c7a31f4..cc483062284 100644 --- a/test/xml/test_node.rb +++ b/test/xml/test_node.rb @@ -143,7 +143,7 @@ def test_node_context_parsing_of_malformed_xml_fragment_uses_the_right_class_to_ def test_parse_error_list error_count = xml.errors.length xml.root.parse("") - assert(error_count < xml.errors.length, "errors should have increased") + assert_operator(error_count, :<, xml.errors.length, "errors should have increased") end def test_parse_error_on_fragment_with_empty_document diff --git a/test/xml/test_node_set.rb b/test/xml/test_node_set.rb index 158a92f61f9..0f76bcefdfd 100644 --- a/test/xml/test_node_set.rb +++ b/test/xml/test_node_set.rb @@ -284,22 +284,22 @@ def awesome(ns) assert(node_set_one = xml.xpath("//employee")) assert(node_set_two = xml.xpath("//employee")) - refute_equal(node_set_one.object_id, node_set_two.object_id) + refute_operator(node_set_one.object_id, :==, node_set_two.object_id) refute_same(node_set_one, node_set_two) - assert_equal(node_set_one, node_set_two) + assert_operator(node_set_one, :==, node_set_two) end it "handles comparison to a string" do node_set_one = xml.xpath("//employee") - refute(node_set_one == "asdfadsf") + refute_operator(node_set_one, :==, "asdfadsf") end it "returns false if same elements are out of order" do one = xml.xpath("//employee") two = xml.xpath("//employee") two.push(two.shift) - refute_equal(one, two) + refute_operator(one, :==, two) end it "returns false if one is a subset of the other" do @@ -307,8 +307,8 @@ def awesome(ns) node_set_two = xml.xpath("//employee") node_set_two.delete(node_set_two.first) - refute(node_set_one == node_set_two) - refute(node_set_two == node_set_one) + refute_operator(node_set_one, :==, node_set_two) + refute_operator(node_set_two, :==, node_set_one) end end