Skip to content

Commit

Permalink
docs: Update version and supporting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maxveldink committed Feb 21, 2024
1 parent b4d138c commit 57240a2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2024-02-21

### Added

- Add minitest assertions for Results

### Changed

- Switched to Standard over using Rubocop directly
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
sorbet-result (1.0.0)
sorbet-result (1.1.0)
sorbet-runtime (~> 0.5)

GEM
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@ res = retrieve_user(user_id)

If the above chain does not fail, the `puts` statement is never run. If the chain does yield a `Failure`, the `puts` block is executed and the `Failure` is ultimately returned.

### Testing

We ship with a few Minitest assertions that can be used to easily verify Results.

```ruby
# test_helper.rb

require "minitest/results_assertions"
# You also need add this to `sorbet/tapioca/require.rb` and rebuild the Minitest gem RBIs

# *_test.rb

@success = Typed::Success.new("Test Payload")
@failure = Typed::Failure.new("Test Error")

assert_success(@success)
assert_failure(@failure)
assert_payload("Test Payload", @success)
assert_error("Test Error", @failure)

# We also have the `refute_*` counterparts
```

## Why use Results?

Let's say you're working on a method that reaches out to an API and fetches a resource. We hope to get a successful response and continue on in our program, but you can imagine several scenarios where we don't get that response: our authentication could fail, the server could return a 5XX response code, or the resource we were querying could have moved or not exist any more.
Expand Down
2 changes: 1 addition & 1 deletion sorbet-result.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = "sorbet-result"
spec.version = "1.0.0"
spec.version = "1.1.0"
spec.authors = ["Max VelDink"]
spec.email = ["[email protected]"]

Expand Down

0 comments on commit 57240a2

Please sign in to comment.