https://github.com/kachick/irb-power_assert
power_assert in irb
https://github.com/kachick/irb-power_assert
irb power-assert repl ruby
Last synced: 12 months ago
JSON representation
power_assert in irb
- Host: GitHub
- URL: https://github.com/kachick/irb-power_assert
- Owner: kachick
- License: mit
- Created: 2021-05-16T08:14:45.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T01:59:28.000Z (over 1 year ago)
- Last Synced: 2024-10-30T05:28:52.256Z (over 1 year ago)
- Topics: irb, power-assert, repl, ruby
- Language: Ruby
- Homepage:
- Size: 323 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# irb-power_assert
[](https://github.com/kachick/irb-power_assert/actions/workflows/ci-ruby.yml?query=branch%3Amain+)
[](http://badge.fury.io/rb/irb-power_assert)
Use power_assert inspection in irb
## Usage
Tested only in ruby-head and the last 2 stable versions\
So require Ruby 3.3 or higher
```console
$ gem install irb-power_assert
...installed
```
```console
$ irb -r irb-power_assert
# enabled this gem
```
Or specify in your `~/.irbrc` as below
```ruby
require 'irb/power_assert'
```
```console
$ irb
irb(main):004> help pa
Print PowerAssert inspection for the given expression.
```
Then you can use `pa` as an IRB command.
```ruby
irb(main):001:0> pa "0".class == "3".to_i.times.map {|i| i + 1 }.class
"0".class == "3".to_i.times.map {|i| i + 1 }.class
| | | | | |
| | | | | Array
| | | | [1, 2, 3]
| | | #
| | 3
| false
String
=> false
```
No hack is needed in your irbrc
## Thanks!
[ruby/power_assert](https://github.com/ruby/power_assert) is a recent my favorites.\
(the author is [@k-tsj](https://github.com/k-tsj), thank you!)
It is super helpful in complex testing.
I just would get irb version of
[yui-knk/pry-power_assert](https://github.com/yui-knk/pry-power_assert).
Latest IRB is much helpful to [create own command](https://github.com/ruby/irb/pull/886)
Honor should be bestowed upon them.
## References
- [power-assert-js/power-assert](https://github.com/power-assert-js/power-assert)
- [Power Assert in Ruby](https://speakerdeck.com/k_tsj/power-assert-in-ruby)
- [pry-power_assert implementation](https://github.com/yui-knk/pry-power_assert/blob/2d10ee3df8efaf9c448f31d51bff8033a1792739/lib/pry-power_assert.rb#L26-L35)