Skip to content

Commit

Permalink
Update version and document
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwebb76 committed Sep 5, 2022
1 parent e2636b8 commit 495feba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.9.0

* Allow specification of a custom validation handler

1.8.3

* Make sorbet a development dependency
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@ RSpec::Sorbet.allow_doubles!
### `eq` matcher usage with `T::Struct`'s

Using the [`eq` matcher](https://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers:eq) to compare [`T::Struct`'s](https://sorbet.org/docs/tstruct) might not behave as you'd expect whereby two separate instances of the same struct class with identical attributes are not `==` out of the box. The standalone [sorbet-struct-comparable](https://github.com/tricycle/sorbet-struct-comparable) gem may be of interest if you are looking for a simple attribute based comparison that will help make the `eq` matcher behave as you expect.

### Specifying a custom validation handler

You can customise the handler of Sorbet validation errors if you so desire.


```ruby
def handler(signature, opts)
raise MyCustomException, "The options were #{opts}"
end

T::Configuration.call_validation_error_handler = handler
```
2 changes: 1 addition & 1 deletion lib/rspec/sorbet/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

module RSpec
module Sorbet
VERSION = '1.8.3'
VERSION = '1.9.0'
end
end
4 changes: 2 additions & 2 deletions spec/lib/rspec/sorbet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def greet_others(others)
module M123
class Animal; end
end

let(:my_instance_double) { instance_double(String) }
let(:my_person) do
Person.new('Sam', 'Giles')
Expand Down Expand Up @@ -150,7 +150,7 @@ def initialize(message)
end

specify do
# Checking to ensure the invalid calls rasies the error in the custom handler
# Checking to ensure the invalid calls raises the error in the custom handler
expect { PassthroughSig.new(123) }.to raise_error ArgumentError, 'foo'
end

Expand Down

0 comments on commit 495feba

Please sign in to comment.