https://github.com/trailblazer/trailblazer-test
Super strong, non-verbose tests for your operations.
https://github.com/trailblazer/trailblazer-test
Last synced: 6 months ago
JSON representation
Super strong, non-verbose tests for your operations.
- Host: GitHub
- URL: https://github.com/trailblazer/trailblazer-test
- Owner: trailblazer
- Created: 2017-07-08T11:01:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T10:25:36.000Z (8 months ago)
- Last Synced: 2025-05-07T20:42:29.084Z (6 months ago)
- Language: Ruby
- Homepage:
- Size: 272 KB
- Stars: 11
- Watchers: 9
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
Awesome Lists containing this project
README
# Trailblazer::Test
_Assertions and helpers for operation unit tests._
The [comprehensive docs are here](https://trailblazer.to/2.1/docs/test/).
Read our introducing blog post for a better overview.
## Installation
Add the following line to your project's `Gemfile`.
```ruby
gem "trailblazer-test", ">= 1.0.0", "< 2.0.0"
```
## Overview
This gem adds the following assertions and helpers:
* `#assert_pass` to test an operation terminating with success.
* `#assert_fail` to assert validation errors and the like.
* `#mock_step` helping the replace steps with stubs.
## Example
An example test case checking if an operation passed and created a model could look as follows.
```ruby
# test/operation/memo_test.rb
require "test_helper"
class MemoOperationTest < Minitest::Spec
Trailblazer::Test.module!(self) # install our helpers.
it "passes with valid input" do
# ...
assert_pass Memo::Operation::Create, input,
content: "Stock up beer",
persisted?: true,
id: ->(asserted:, **) { asserted.id > 0 }
end
end
```