Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosylilly/power_assert.cr
PowerAssert provides the more powerful assertion to you.
https://github.com/rosylilly/power_assert.cr
Last synced: 5 days ago
JSON representation
PowerAssert provides the more powerful assertion to you.
- Host: GitHub
- URL: https://github.com/rosylilly/power_assert.cr
- Owner: rosylilly
- License: mit
- Created: 2015-06-25T02:29:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-26T03:47:23.000Z (over 8 years ago)
- Last Synced: 2024-12-22T13:14:56.131Z (15 days ago)
- Language: Crystal
- Homepage: https://github.com/rosylilly/power_assert.cr
- Size: 16.6 KB
- Stars: 41
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# power_assert.cr
[![docrystal.org](http://www.docrystal.org/badge.svg)](http://www.docrystal.org/github.com/rosylilly/power_assert.cr)
PowerAssert provides the more powerful assertion to you.
## Usage
Very simple.
```crystal
# spec/my_lib_spec.crdescribe MyLib do
describe ".major_version" do
it "should be equal 1" do
assert MyLib.major_version == 1
end
end
end
```If `MyLib.major_version` is 2:
```
FFailures:
1) MyLib .major_version should be equal 1
Failure/Error: assert MyLib.major_version == 1MyLib.major_version == 1
| | |
| | 1
| false
2# ./spec/my_lib_spec.cr:6
```more examples in `spec`.
:tada: Happy testing! :tada:
## Configure
- `global_indent : Int` : A indent size of assertion messages.
- `sort_by : Symbol` : Sort order of breakdowns. allowed: `:default`, `:reverse`, `:left` and `:right`.
- `expand_block : Bool` : Show block's codes in the breakdown.## Example Outputs
Run `crystal spec`.
```
FFFFFFFailures:
1) PowerAssert Simple operators should be fail
Failure/Error: assert 1 == 21 == 2
| | |
| false
| |
| 2
1# ./spec/power_assert_spec.cr:23
2) PowerAssert Simple operators should be fail
Failure/Error: assert 1 > 21 > 2
| | |
| false
| |
| 2
1# ./spec/power_assert_spec.cr:27
3) PowerAssert Method call should be fail
Failure/Error: assert falsey == truefalsey == true
| | |
| false
| |
| true
false# ./spec/power_assert_spec.cr:33
4) PowerAssert Method call should be fail
Failure/Error: assert example.falsey(one, two, three)example.falsey(one, two, three)
| | | | |
| false | | |
| 1 | |
| 2 |
| 3
## ./spec/power_assert_spec.cr:42
5) PowerAssert Method call should be fail
Failure/Error: assert example.one == 2example.one == 2
| | | |
| | false
| | |
| | 2
| 1
## ./spec/power_assert_spec.cr:48
6) PowerAssert Method call should be fail
Failure/Error: assert array.any? { |n| n == 0 }.nil?array.any? { ... }.nil?
| | |
| | false
| false
[1, 2, 3]# ./spec/power_assert_spec.cr:54
Finished in 2.16 milliseconds
6 examples, 6 failures, 0 errors, 0 pendingFailed examples:
crystal spec ./spec/power_assert_spec.cr:22 # PowerAssert Simple operators should be fail
crystal spec ./spec/power_assert_spec.cr:26 # PowerAssert Simple operators should be fail
crystal spec ./spec/power_assert_spec.cr:32 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:36 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:45 # PowerAssert Method call should be fail
crystal spec ./spec/power_assert_spec.cr:51 # PowerAssert Method call should be fail
Program terminated abnormally with error code: 256
```## ToDo
- [ ] Support `a == b && c == d`
## License
Distributed under the MIT License. Please see LICENSE for details
## Credits
- Sho Kusano [@rosylilly](https://github.com/rosylilly) for the Crystal implementation
- Takuto Wada [@twada](https://github.com/twada) for the original JavaScript implementation. power_assert.cr is inspired by [power-assert](https://www.npmjs.com/package/power-assert).