You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RSpec.describeMyClassdodescribe'.new'dosubject(:my_class){described_class.new(name)}# RBS test needs to skip this context as we're intentionally violating types here.context'when given an invalid name'dolet(:name){123}it{expect{my_class}.toraise_error(ArgumentError,/Invalid name/)}end# RBS test should not skip this contextcontext'when given a valid name'dolet(:name){'foo'}it{expect{my_class}.not_toraise_error}it'is expected to set the name'doexpect(my_class).tohave_attributes(name: :foo)endendendend
While it's great that RBS can catch these type errors its only really beneficial if those who use your gem as a dependency are also using RBS on their project. So we still need to write in protections like this but are unable to test them because the test in this example will raise an RBS TypeError. Additionally we don't want to completely turn off RBS for the initialize method with the %a{rbs:test:skip} annotation as it's just this single test that will raise the error.
The obvious work around here is to have the name argument in the initializer be untyped however that reduces the clarity of the signature making the end user believe they may pass whatever they would like for name to the initializer.
The text was updated successfully, but these errors were encountered:
This is a FANTASTIC work around, my only complaint is having to run the test suite twice (once for all specs, and once with RBS using exclusion of the tag).
It would be awesome if you could turn RBS test on and off for single unit tests.
Given the following example:
and the following test:
While it's great that RBS can catch these type errors its only really beneficial if those who use your gem as a dependency are also using RBS on their project. So we still need to write in protections like this but are unable to test them because the test in this example will raise an RBS TypeError. Additionally we don't want to completely turn off RBS for the initialize method with the
%a{rbs:test:skip}
annotation as it's just this single test that will raise the error.The obvious work around here is to have the
name
argument in the initializer beuntyped
however that reduces the clarity of the signature making the end user believe they may pass whatever they would like forname
to the initializer.The text was updated successfully, but these errors were encountered: