Skip to content

Commit 5e647eb

Browse files
authored
Merge pull request #2571 from Shopify/Alex/fix-assert_raises-calls
Fix `assert_raises` calls
2 parents e72c97a + 7c6c7d6 commit 5e647eb

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

spec/tapioca/dsl/compiler_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def decorate
191191
klass.create_method(
192192
method.name.to_s,
193193
parameters: [],
194-
return_type: "void)",
194+
return_type: "void)", # intentional mistake, leading to `sig { returns(void)) }`
195195
class_method: false,
196196
)
197197
end
@@ -220,9 +220,10 @@ def foo(d:, e: 42, **f, &blk); end
220220
end
221221
RUBY
222222

223-
assert_raises(SyntaxError, /void\)/) do
224-
rbi_for(:Post)
225-
end
223+
e = assert_raises(SyntaxError) { rbi_for(:Post) }
224+
225+
assert_match('unexpected token ")"', e.message)
226+
assert_match("sig { returns(void)) }", e.message)
226227
end
227228
end
228229
end

spec/tapioca/dsl/compilers/json_api_client_resource_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ class Post < JsonApiClient::Resource
178178
# We let the generation raise, the user should not define an association without a corresponding class.
179179
# The association will be unusable anyway.
180180

181-
assert_raises(NameError, /uninitialized constant Post::User/) do
182-
rbi_for(:Post)
183-
end
181+
e = assert_raises(NameError) { rbi_for(:Post) }
182+
183+
assert_match(/uninitialized constant Post::User/, e.message)
184184
end
185185

186186
it "generates associations" do

spec/tapioca/helpers/sorbet_helper_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Tapioca::SorbetHelperSpec < Minitest::Spec
2828
end
2929

3030
it "raises for an unknown feature check" do
31-
assert_raises do
31+
assert_raises(RuntimeError) do
3232
sorbet_supports?(:unknown_feature_name)
3333
end
3434
end

0 commit comments

Comments
 (0)