Skip to content

Commit e6ad12b

Browse files
committed
Use assert_raise instead of assert_raises
1 parent ef8bb17 commit e6ad12b

File tree

12 files changed

+61
-61
lines changed

12 files changed

+61
-61
lines changed

test/psych/test_class.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ module Foo
77
end
88

99
def test_cycle_anonymous_class
10-
assert_raises(::TypeError) do
10+
assert_raise(::TypeError) do
1111
assert_cycle(Class.new)
1212
end
1313
end
1414

1515
def test_cycle_anonymous_module
16-
assert_raises(::TypeError) do
16+
assert_raise(::TypeError) do
1717
assert_cycle(Module.new)
1818
end
1919
end

test/psych/test_document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_emit_multitag
3030
end
3131

3232
def test_emit_bad_tag
33-
assert_raises(RuntimeError) do
33+
assert_raise(RuntimeError) do
3434
@doc.tag_directives = [['!']]
3535
@stream.yaml
3636
end

test/psych/test_emitter.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_emit_utf_8
4040
end
4141

4242
def test_start_stream_arg_error
43-
assert_raises(TypeError) do
43+
assert_raise(TypeError) do
4444
@emitter.start_stream 'asdfasdf'
4545
end
4646
end
@@ -56,7 +56,7 @@ def test_start_doc_arg_error
5656
[[], [nil,nil], false],
5757
[[1,1], [[nil, "tag:TALOS"]], 0],
5858
].each do |args|
59-
assert_raises(TypeError) do
59+
assert_raise(TypeError) do
6060
@emitter.start_document(*args)
6161
end
6262
end
@@ -73,7 +73,7 @@ def test_scalar_arg_error
7373
['foo', nil, nil, false, true, :foo],
7474
[nil, nil, nil, false, true, 1],
7575
].each do |args|
76-
assert_raises(TypeError) do
76+
assert_raise(TypeError) do
7777
@emitter.scalar(*args)
7878
end
7979
end
@@ -83,11 +83,11 @@ def test_start_sequence_arg_error
8383
@emitter.start_stream Psych::Nodes::Stream::UTF8
8484
@emitter.start_document [], [], false
8585

86-
assert_raises(TypeError) do
86+
assert_raise(TypeError) do
8787
@emitter.start_sequence(nil, Object.new, true, 1)
8888
end
8989

90-
assert_raises(TypeError) do
90+
assert_raise(TypeError) do
9191
@emitter.start_sequence(nil, nil, true, :foo)
9292
end
9393
end

test/psych/test_encoding.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_io_shiftjis
6363
# If the external encoding isn't utf8, utf16le, or utf16be, we cannot
6464
# process the file.
6565
File.open(t.path, 'r', :encoding => 'SHIFT_JIS') do |f|
66-
assert_raises Psych::SyntaxError do
66+
assert_raise Psych::SyntaxError do
6767
Psych.load(f)
6868
end
6969
end
@@ -121,7 +121,7 @@ def test_io_utf8_read_as_binary
121121
def test_emit_alias
122122
@emitter.start_stream Psych::Parser::UTF8
123123
@emitter.start_document [], [], true
124-
e = assert_raises(RuntimeError) do
124+
e = assert_raise(RuntimeError) do
125125
@emitter.alias 'ドラえもん'.encode('EUC-JP')
126126
end
127127
assert_match(/alias value/, e.message)

test/psych/test_exception.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,51 +44,51 @@ def test_naming_exception
4444
end
4545

4646
def test_load_takes_file
47-
ex = assert_raises(Psych::SyntaxError) do
47+
ex = assert_raise(Psych::SyntaxError) do
4848
Psych.load '--- `'
4949
end
5050
assert_nil ex.file
5151

52-
ex = assert_raises(Psych::SyntaxError) do
52+
ex = assert_raise(Psych::SyntaxError) do
5353
Psych.load '--- `', filename: 'meow'
5454
end
5555
assert_equal 'meow', ex.file
5656

5757
# deprecated interface
58-
ex = assert_raises(Psych::SyntaxError) do
58+
ex = assert_raise(Psych::SyntaxError) do
5959
Psych.load '--- `', 'deprecated'
6060
end
6161
assert_equal 'deprecated', ex.file
6262
end
6363

6464
def test_psych_parse_stream_takes_file
65-
ex = assert_raises(Psych::SyntaxError) do
65+
ex = assert_raise(Psych::SyntaxError) do
6666
Psych.parse_stream '--- `'
6767
end
6868
assert_nil ex.file
6969
assert_match '(<unknown>)', ex.message
7070

71-
ex = assert_raises(Psych::SyntaxError) do
71+
ex = assert_raise(Psych::SyntaxError) do
7272
Psych.parse_stream '--- `', filename: 'omg!'
7373
end
7474
assert_equal 'omg!', ex.file
7575
assert_match 'omg!', ex.message
7676
end
7777

7878
def test_load_stream_takes_file
79-
ex = assert_raises(Psych::SyntaxError) do
79+
ex = assert_raise(Psych::SyntaxError) do
8080
Psych.load_stream '--- `'
8181
end
8282
assert_nil ex.file
8383
assert_match '(<unknown>)', ex.message
8484

85-
ex = assert_raises(Psych::SyntaxError) do
85+
ex = assert_raise(Psych::SyntaxError) do
8686
Psych.load_stream '--- `', filename: 'omg!'
8787
end
8888
assert_equal 'omg!', ex.file
8989

9090
# deprecated interface
91-
ex = assert_raises(Psych::SyntaxError) do
91+
ex = assert_raise(Psych::SyntaxError) do
9292
Psych.load_stream '--- `', 'deprecated'
9393
end
9494
assert_equal 'deprecated', ex.file
@@ -99,7 +99,7 @@ def test_parse_file_exception
9999
t.binmode
100100
t.write '--- `'
101101
t.close
102-
ex = assert_raises(Psych::SyntaxError) do
102+
ex = assert_raise(Psych::SyntaxError) do
103103
Psych.parse_file t.path
104104
end
105105
assert_equal t.path, ex.file
@@ -111,7 +111,7 @@ def test_load_file_exception
111111
t.binmode
112112
t.write '--- `'
113113
t.close
114-
ex = assert_raises(Psych::SyntaxError) do
114+
ex = assert_raise(Psych::SyntaxError) do
115115
Psych.load_file t.path
116116
end
117117
assert_equal t.path, ex.file
@@ -123,34 +123,34 @@ def test_safe_load_file_exception
123123
t.binmode
124124
t.write '--- `'
125125
t.close
126-
ex = assert_raises(Psych::SyntaxError) do
126+
ex = assert_raise(Psych::SyntaxError) do
127127
Psych.safe_load_file t.path
128128
end
129129
assert_equal t.path, ex.file
130130
}
131131
end
132132

133133
def test_psych_parse_takes_file
134-
ex = assert_raises(Psych::SyntaxError) do
134+
ex = assert_raise(Psych::SyntaxError) do
135135
Psych.parse '--- `'
136136
end
137137
assert_match '(<unknown>)', ex.message
138138
assert_nil ex.file
139139

140-
ex = assert_raises(Psych::SyntaxError) do
140+
ex = assert_raise(Psych::SyntaxError) do
141141
Psych.parse '--- `', filename: 'omg!'
142142
end
143143
assert_match 'omg!', ex.message
144144

145145
# deprecated interface
146-
ex = assert_raises(Psych::SyntaxError) do
146+
ex = assert_raise(Psych::SyntaxError) do
147147
Psych.parse '--- `', 'deprecated'
148148
end
149149
assert_match 'deprecated', ex.message
150150
end
151151

152152
def test_attributes
153-
e = assert_raises(Psych::SyntaxError) {
153+
e = assert_raise(Psych::SyntaxError) {
154154
Psych.load '--- `foo'
155155
}
156156

test/psych/test_merge_keys.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_missing_merge_key
117117
bar:
118118
<< : *foo
119119
eoyml
120-
exp = assert_raises(Psych::BadAlias) { Psych.load yaml }
120+
exp = assert_raise(Psych::BadAlias) { Psych.load yaml }
121121
assert_match 'foo', exp.message
122122
end
123123

test/psych/test_parser.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_exception_memory_leak
6363

6464
parser = Psych::Parser.new klass.new
6565
2.times {
66-
assert_raises(RuntimeError, method.to_s) do
66+
assert_raise(RuntimeError, method.to_s) do
6767
parser.parse yaml
6868
end
6969
}
@@ -77,7 +77,7 @@ def test_multiparse
7777
end
7878

7979
def test_filename
80-
ex = assert_raises(Psych::SyntaxError) do
80+
ex = assert_raise(Psych::SyntaxError) do
8181
@parser.parse '--- `', 'omg!'
8282
end
8383
assert_match 'omg!', ex.message
@@ -180,7 +180,7 @@ def test_bogus_io
180180
def o.external_encoding; nil end
181181
def o.read len; self end
182182

183-
assert_raises(TypeError) do
183+
assert_raise(TypeError) do
184184
@parser.parse o
185185
end
186186
end
@@ -193,23 +193,23 @@ def test_parse_io
193193
end
194194

195195
def test_syntax_error
196-
assert_raises(Psych::SyntaxError) do
196+
assert_raise(Psych::SyntaxError) do
197197
@parser.parse("---\n\"foo\"\n\"bar\"\n")
198198
end
199199
end
200200

201201
def test_syntax_error_twice
202-
assert_raises(Psych::SyntaxError) do
202+
assert_raise(Psych::SyntaxError) do
203203
@parser.parse("---\n\"foo\"\n\"bar\"\n")
204204
end
205205

206-
assert_raises(Psych::SyntaxError) do
206+
assert_raise(Psych::SyntaxError) do
207207
@parser.parse("---\n\"foo\"\n\"bar\"\n")
208208
end
209209
end
210210

211211
def test_syntax_error_has_path_for_string
212-
e = assert_raises(Psych::SyntaxError) do
212+
e = assert_raise(Psych::SyntaxError) do
213213
@parser.parse("---\n\"foo\"\n\"bar\"\n")
214214
end
215215
assert_match '(<unknown>):', e.message
@@ -219,7 +219,7 @@ def test_syntax_error_has_path_for_io
219219
io = StringIO.new "---\n\"foo\"\n\"bar\"\n"
220220
def io.path; "hello!"; end
221221

222-
e = assert_raises(Psych::SyntaxError) do
222+
e = assert_raise(Psych::SyntaxError) do
223223
@parser.parse(io)
224224
end
225225
assert_match "(#{io.path}):", e.message

test/psych/test_psych.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def teardown
1616
end
1717

1818
def test_line_width_invalid
19-
assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
19+
assert_raise(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
2020
end
2121

2222
def test_line_width_no_limit
@@ -61,7 +61,7 @@ def test_version_bool
6161
end
6262

6363
def test_load_argument_error
64-
assert_raises(TypeError) do
64+
assert_raise(TypeError) do
6565
Psych.load nil
6666
end
6767
end
@@ -75,15 +75,15 @@ def test_parse_default_fallback
7575
end
7676

7777
def test_parse_raises_on_bad_input
78-
assert_raises(Psych::SyntaxError) { Psych.parse("--- `") }
78+
assert_raise(Psych::SyntaxError) { Psych.parse("--- `") }
7979
end
8080

8181
def test_parse_with_fallback
8282
assert_equal 42, Psych.parse("", fallback: 42)
8383
end
8484

8585
def test_non_existing_class_on_deserialize
86-
e = assert_raises(ArgumentError) do
86+
e = assert_raise(ArgumentError) do
8787
Psych.load("--- !ruby/object:NonExistent\nfoo: 1")
8888
end
8989
assert_equal 'undefined class/module NonExistent', e.message
@@ -143,7 +143,7 @@ def test_load_stream_default_fallback
143143
end
144144

145145
def test_load_stream_raises_on_bad_input
146-
assert_raises(Psych::SyntaxError) { Psych.load_stream("--- `") }
146+
assert_raise(Psych::SyntaxError) { Psych.load_stream("--- `") }
147147
end
148148

149149
def test_parse_stream
@@ -175,7 +175,7 @@ def test_parse_stream_with_block_default_fallback
175175
end
176176

177177
def test_parse_stream_raises_on_bad_input
178-
assert_raises(Psych::SyntaxError) { Psych.parse_stream("--- `") }
178+
assert_raise(Psych::SyntaxError) { Psych.parse_stream("--- `") }
179179
end
180180

181181
def test_add_builtin_type
@@ -325,7 +325,7 @@ def test_safe_load_file_with_permitted_classe
325325
t.write("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n")
326326
t.close
327327
assert_equal 0..42, Psych.safe_load_file(t.path, permitted_classes: [Range])
328-
assert_raises(Psych::DisallowedClass) {
328+
assert_raise(Psych::DisallowedClass) {
329329
Psych.safe_load_file(t.path)
330330
}
331331
}

0 commit comments

Comments
 (0)