Skip to content

Commit

Permalink
style(rubocop): Minitest/AssertOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Oct 9, 2023
1 parent 20a2272 commit 6740c5c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/html4/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
10 changes: 5 additions & 5 deletions test/test_memory_leak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -289,28 +289,28 @@ def test_object_space_memsize_of
<child>asdf</child>
</root>
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))
<root>
<child a="b" c="d">asdf</child>
</root>
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))
<root>
<child>asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</child>
</root>
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))
<root>
<superduperamazingchild>asdf</superduperamazingchild>
</root>
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
Expand Down
4 changes: 2 additions & 2 deletions test/xml/sax/test_push_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def error(msg)
</p>
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/, "")
Expand All @@ -186,7 +186,7 @@ def error(msg)
# This is ISO_8859-1:
parser << "<?xml version='1.0' encoding='UTF-8'?><r>Gau\337</r>"
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
Expand Down
2 changes: 1 addition & 1 deletion test/xml/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion test/xml/test_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<hello>")
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
Expand Down
12 changes: 6 additions & 6 deletions test/xml/test_node_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,31 +284,31 @@ 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
node_set_one = xml.xpath("//employee")
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

Expand Down

0 comments on commit 6740c5c

Please sign in to comment.