From 33024ce2b048bb27c780cbe7f6b561b0f6cd709d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 8 Jun 2023 21:52:49 +0900 Subject: [PATCH] Prefer `assert_include` for simple strings --- test/psych/visitors/test_emitter.rb | 16 ++++++++-------- test/psych/visitors/test_yaml_tree.rb | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/psych/visitors/test_emitter.rb b/test/psych/visitors/test_emitter.rb index 70adbb9c..8bcf5491 100644 --- a/test/psych/visitors/test_emitter.rb +++ b/test/psych/visitors/test_emitter.rb @@ -61,9 +61,9 @@ def test_document_implicit_end @visitor.accept s - assert_match(/key: value/, @io.string) + assert_include(@io.string, "key: value") assert_equal @io.string, s.yaml - assert(/\.\.\./ !~ s.yaml) + assert_not_include(s.yaml, "...") end def test_scalar @@ -76,7 +76,7 @@ def test_scalar @visitor.accept s - assert_match(/hello/, @io.string) + assert_include(@io.string, "hello") assert_equal @io.string, s.yaml end @@ -90,8 +90,8 @@ def test_scalar_with_tag @visitor.accept s - assert_match(/str/, @io.string) - assert_match(/hello/, @io.string) + assert_include(@io.string, "str") + assert_include(@io.string, "hello") assert_equal @io.string, s.yaml end @@ -107,7 +107,7 @@ def test_sequence @visitor.accept s - assert_match(/- hello/, @io.string) + assert_include(@io.string, "- hello") assert_equal @io.string, s.yaml end @@ -122,7 +122,7 @@ def test_mapping @visitor.accept s - assert_match(/key: value/, @io.string) + assert_include(@io.string, "key: value") assert_equal @io.string, s.yaml end @@ -137,7 +137,7 @@ def test_alias @visitor.accept s - assert_match(/&A key: \*A/, @io.string) + assert_include(@io.string, "&A key: \*A") assert_equal @io.string, s.yaml end end diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 4c48670f..01e68513 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -34,7 +34,7 @@ def test_yaml_tree_can_take_an_emitter v << "hello world" v.finish - assert_match "hello world", io.string + assert_include io.string, "hello world" end def test_binary_formatting @@ -167,9 +167,9 @@ def test_float end def test_string - assert_match(/'017'/, Psych.dump({'a' => '017'})) - assert_match(/'019'/, Psych.dump({'a' => '019'})) - assert_match(/'01818'/, Psych.dump({'a' => '01818'})) + assert_include(Psych.dump({'a' => '017'}), "'017'") + assert_include(Psych.dump({'a' => '019'}), "'019'") + assert_include(Psych.dump({'a' => '01818'}), "'01818'") end # http://yaml.org/type/null.html