summaryrefslogtreecommitdiffhomepage
path: root/test/rels
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-04-13 13:13:34 +0200
committerGeremia Taglialatela <[email protected]>2023-05-03 16:05:17 +0200
commit350f7ae9a04f3d39c099cc54f7c04bf31f385d96 (patch)
treee84af2a70d3b18a0b94c784338faf48215c9c8a8 /test/rels
parente81036b76e734ab03fac31faafb9732f6b3b2928 (diff)
downloadcaxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.tar.gz
caxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.zip
Add RuboCop Minitest
Diffstat (limited to 'test/rels')
-rw-r--r--test/rels/tc_relationship.rb8
-rw-r--r--test/rels/tc_relationships.rb3
2 files changed, 9 insertions, 2 deletions
diff --git a/test/rels/tc_relationship.rb b/test/rels/tc_relationship.rb
index 1a9df27a..71208ec7 100644
--- a/test/rels/tc_relationship.rb
+++ b/test/rels/tc_relationship.rb
@@ -4,12 +4,14 @@ class TestRelationships < Test::Unit::TestCase
def test_instances_with_different_attributes_have_unique_ids
rel_1 = Axlsx::Relationship.new(Object.new, Axlsx::WORKSHEET_R, 'target')
rel_2 = Axlsx::Relationship.new(Object.new, Axlsx::COMMENT_R, 'foobar')
+
assert_not_equal rel_1.Id, rel_2.Id
end
def test_instances_with_same_attributes_share_id
source_obj = Object.new
instance = Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, 'target')
+
assert_equal instance.Id, Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, 'target').Id
end
@@ -18,6 +20,7 @@ class TestRelationships < Test::Unit::TestCase
t1 = Thread.new { cache1 = Axlsx::Relationship.ids_cache }
t2 = Thread.new { cache2 = Axlsx::Relationship.ids_cache }
[t1, t2].each(&:join)
+
assert_not_same(cache1, cache2)
end
@@ -25,10 +28,12 @@ class TestRelationships < Test::Unit::TestCase
source_obj = Object.new
rel_1 = Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, 'target')
rel_2 = Axlsx::Relationship.new(source_obj, Axlsx::WORKSHEET_R, '../target')
+
assert_equal rel_1.Id, rel_2.Id
rel_3 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, 'target', :target_mode => :External)
rel_4 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, '../target', :target_mode => :External)
+
assert_not_equal rel_3.Id, rel_4.Id
end
@@ -46,6 +51,7 @@ class TestRelationships < Test::Unit::TestCase
def test_ampersand_escaping_in_target
r = Axlsx::Relationship.new(nil, Axlsx::HYPERLINK_R, "http://example.com?foo=1&bar=2", :target_mod => :External)
doc = Nokogiri::XML(r.to_xml_string)
- assert_equal(doc.xpath("//Relationship[@Target='http://example.com?foo=1&bar=2']").size, 1)
+
+ assert_equal(1, doc.xpath("//Relationship[@Target='http://example.com?foo=1&bar=2']").size)
end
end
diff --git a/test/rels/tc_relationships.rb b/test/rels/tc_relationships.rb
index 35adbc9b..ba153ce7 100644
--- a/test/rels/tc_relationships.rb
+++ b/test/rels/tc_relationships.rb
@@ -9,6 +9,7 @@ class TestRelationships < Test::Unit::TestCase
rels = Axlsx::Relationships.new
rels << rel_1
rels << rel_2
+
assert_equal rel_1, rels.for(source_obj_1)
assert_equal rel_2, rels.for(source_obj_2)
end
@@ -31,6 +32,6 @@ class TestRelationships < Test::Unit::TestCase
errors << error
end
- assert(errors.empty?)
+ assert_empty(errors)
end
end