docs/sigs.md in rbs-3.1.3 vs docs/sigs.md in rbs-3.2.0.pre.1
- old
+ new
@@ -16,11 +16,11 @@
## Testing signatures
When you finish writing signature, you may want to test the signature.
rbs provides a feature to test your signature.
-```
+```console
$ RBS_TEST_TARGET='Foo::*' bundle exec ruby -r rbs/test/setup test/foo_test.rb
```
The test installs instrumentations to spy the method calls and check if arguments/return values are correct with respect to the type of the method in signature.
If errors are reported by the test, you will fix the signature.
@@ -72,11 +72,11 @@
### DuplicatedMethodDefinitionError
The error is reported when a method is defined multiple times, as RBS does not allow duplicate method definitions. When you need to overload a method, use the `...` syntax:
-```ruby
+```rbs
# First definition
class C
def foo: () -> untyped
end
@@ -97,18 +97,18 @@
### Loading the library
You need to require `rbs/test/setup` for signature testing.
You can do it using `-r` option through command line argument or the `RUBYOPT` environment variable.
-```
+```console
$ ruby -r rbs/test/setup run_tests.rb
$ RUBYOPT='-rrbs/test/setup' rake test
```
When you are using Bundler, you may need to require `bundler/setup` explicitly.
-```
+```console
$ RUBYOPT='-rbundler/setup -rrbs/test/setup' bundle exec rake test
```
### Environment variables
@@ -128,11 +128,11 @@
`RBS_TEST_OPT` is to pass the options for rbs handling.
You may need to specify `-r` or `-I` to load signatures.
The default is `-I sig`.
-```
+```shell
RBS_TEST_OPT='-r pathname -I sig'
```
Replacing `pathname` with the `stdlib` you want to include. For example, if you need to load `Set` and `BigDecimal` in `stdlib`, you would need to have `RBS_TEST_OPT='-r set -r bigdecimal -I sig'`
@@ -142,11 +142,11 @@
If the environment variable is set, it raises an exception when a type error is detected.
You can see the backtrace how the type error is caused and debug your program or signature.
So, a typical command line to start the test would look like the following:
-```
+```console
$ RBS_TEST_LOGLEVEL=error \
RBS_TEST_TARGET='Kaigi::*' \
RBS_TEST_SKIP='Kaigi::MonkeyPatch' \
RBS_TEST_OPT='-rset -rpathname -Isig -Iprivate' \
RBS_TEST_RAISE=true \
@@ -158,10 +158,10 @@
### Skipping a method
You can skip installing the instrumentation per-method basis using `rbs:test:skip` annotation.
-```
+```rbs
class String
%a{rbs:test:skip} def =~: (Regexp) -> Integer?
end
```