https://github.com/fixrb/matchi-fix
A Fix expectation matcher compatible with Matchi.
https://github.com/fixrb/matchi-fix
ruby
Last synced: 4 months ago
JSON representation
A Fix expectation matcher compatible with Matchi.
- Host: GitHub
- URL: https://github.com/fixrb/matchi-fix
- Owner: fixrb
- License: mit
- Created: 2015-09-07T00:25:35.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T19:01:03.000Z (about 2 years ago)
- Last Synced: 2024-08-10T09:14:34.163Z (almost 2 years ago)
- Topics: ruby
- Language: Ruby
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Matchi::Fix
[](https://github.com/fixrb/matchi-fix/releases)
[](https://rubydoc.info/github/fixrb/matchi-fix/main)
[](https://github.com/fixrb/matchi-fix/raw/main/LICENSE.md)
[Matchi](https://github.com/fixrb/matchi)-compatible matcher for testing implementations against [Fix](https://github.com/fixrb/fix) specifications.
## Installation
Add this line to your application's Gemfile:
```ruby
gem "matchi-fix"
```
And then execute:
```shell
bundle install
```
Or install it yourself:
```shell
gem install matchi-fix
```
## Description
A Matchi-compatible matcher that allows testing objects against Fix specifications.
Enables verification of implementation conformance to Fix test specifications
across different testing frameworks like Minitest and RSpec. Integrates seamlessly
with the Fix testing framework's powerful specification system while maintaining
Matchi's clean matcher interface.
## Usage
To make __Matchi::Fix__ available:
```ruby
require "matchi/fix"
```
The Fix matcher allows testing values against Fix specifications. After requiring `matchi-fix`, you can use the `Fix` matcher in your tests through anonymous specification:
```ruby
Matchi::Fix.new { it MUST be 42 }.match? { 42 } # => true
```
or through registered specification by name:
```ruby
# First, define a Fix specification
Fix :Calculator do
on(:add, 2, 3) do
it MUST eq 5
end
on(:multiply, 2, 3) do
it MUST eq 6
end
end
# Then use the matcher to test implementations
calculator = MyCalculator.new
# Using direct matcher syntax
Matchi::Fix.new(:Calculator).matches?(calculator) #=> true/false
```
### Error Handling
On missing specifications:
```ruby
Matchi::Fix.new(:NonExistent)
# => KeyError
```
On passing both specification name and specification code:
```ruby
Matchi::Fix.new(:SpecName) { "Spec block" }
# => ArgumentError
```
## Contact
* Source code: https://github.com/fixrb/matchi-fix
## Versioning
__Matchi::Fix__ follows [Semantic Versioning 2.0](https://semver.org/).
## License
The [gem](https://rubygems.org/gems/matchi-fix) is available as open source under the terms of the [MIT License](https://github.com/fixrb/matchi-fix/raw/main/LICENSE.md).
## Sponsors
This project is sponsored by [Sashité](https://sashite.com/)