Skip to content

Commit fac85ac

Browse files
authored
Merge pull request #632 from nobu/test-include
Prefer `assert_include` for simple strings
2 parents 1dabdc3 + 33024ce commit fac85ac

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

test/psych/visitors/test_emitter.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def test_document_implicit_end
6161

6262
@visitor.accept s
6363

64-
assert_match(/key: value/, @io.string)
64+
assert_include(@io.string, "key: value")
6565
assert_equal @io.string, s.yaml
66-
assert(/\.\.\./ !~ s.yaml)
66+
assert_not_include(s.yaml, "...")
6767
end
6868

6969
def test_scalar
@@ -76,7 +76,7 @@ def test_scalar
7676

7777
@visitor.accept s
7878

79-
assert_match(/hello/, @io.string)
79+
assert_include(@io.string, "hello")
8080
assert_equal @io.string, s.yaml
8181
end
8282

@@ -90,8 +90,8 @@ def test_scalar_with_tag
9090

9191
@visitor.accept s
9292

93-
assert_match(/str/, @io.string)
94-
assert_match(/hello/, @io.string)
93+
assert_include(@io.string, "str")
94+
assert_include(@io.string, "hello")
9595
assert_equal @io.string, s.yaml
9696
end
9797

@@ -107,7 +107,7 @@ def test_sequence
107107

108108
@visitor.accept s
109109

110-
assert_match(/- hello/, @io.string)
110+
assert_include(@io.string, "- hello")
111111
assert_equal @io.string, s.yaml
112112
end
113113

@@ -122,7 +122,7 @@ def test_mapping
122122

123123
@visitor.accept s
124124

125-
assert_match(/key: value/, @io.string)
125+
assert_include(@io.string, "key: value")
126126
assert_equal @io.string, s.yaml
127127
end
128128

@@ -137,7 +137,7 @@ def test_alias
137137

138138
@visitor.accept s
139139

140-
assert_match(/&A key: \*A/, @io.string)
140+
assert_include(@io.string, "&A key: \*A")
141141
assert_equal @io.string, s.yaml
142142
end
143143
end

test/psych/visitors/test_yaml_tree.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_yaml_tree_can_take_an_emitter
3434
v << "hello world"
3535
v.finish
3636

37-
assert_match "hello world", io.string
37+
assert_include io.string, "hello world"
3838
end
3939

4040
def test_binary_formatting
@@ -167,9 +167,9 @@ def test_float
167167
end
168168

169169
def test_string
170-
assert_match(/'017'/, Psych.dump({'a' => '017'}))
171-
assert_match(/'019'/, Psych.dump({'a' => '019'}))
172-
assert_match(/'01818'/, Psych.dump({'a' => '01818'}))
170+
assert_include(Psych.dump({'a' => '017'}), "'017'")
171+
assert_include(Psych.dump({'a' => '019'}), "'019'")
172+
assert_include(Psych.dump({'a' => '01818'}), "'01818'")
173173
end
174174

175175
# http://yaml.org/type/null.html

0 commit comments

Comments
 (0)